SimSharp icon indicating copy to clipboard operation
SimSharp copied to clipboard

Resource request with timeout

Open kokorins opened this issue 1 year ago • 3 comments

Is it possible to request resource with timeout.

Context: I'm trying to simulate impatience and I stumble upon situation, when an order is stuck for very long on resource request state, I've tried to look through the code but I havent found any possibility to add it easy, am I missing something?

kokorins avatar Sep 07 '24 20:09 kokorins

Sure, the BankRenege sample shows exactly that feature. You can combine events using logical operators | (or) and & (and) which will wake up the process if any event fired (or) or only if all of them fired (and).

abeham avatar Sep 07 '24 22:09 abeham

Hmm, is it possible to release not yet acquired resource?

kokorins avatar Sep 08 '24 10:09 kokorins

Just release it. Request also implements IDisposable so you can use the using pattern to hold it, the dispose callback releases the request.

abeham avatar Sep 08 '24 12:09 abeham