Needs a thread-independent way to do the following (modeled after Monitor.Wait and Monitor.Pulse):
-
Wait - temporarily allow queued Acquire and TryAcquire calls to proceed while waiting for a pulse, blocking the caller until any ISyncScope(s) acquired while waiting are disposed and at least one Pulse has occurred.
- There is much yet to be considered with the mechanics of multiple threads potentially holding an ISyncScope within the same ISyncContext on the same synchronization root (ISyncScope.SyncRoot).
- This is further complicated in that I'm considering a mechanic to pass an ISyncScope from one context to another and/or temporarily join multiple ISyncContext instances.
-
Pulse - flag to, once the ISyncScope is disposed, notify any blocking Wait calls that something changed, allowing them to proceed.
- One potential thought in this area would be to have Pulse re-insert any contexts from a Wait call back into the awaiters queue
- Another thought is to fire any WaitAsync caller continuations via ThreadPool.QueueUserWorkItem or captured caller's synchronization context at the end of the call.
-
WaitAsync - return an awaitable interface that allows other Acquire and TryAcquire calls to proceed while waiting for a pulse. When a pulse is received, the continuation would be called asynchronously in a manner consistent with the behavior of Wait (TBD).
Needs a thread-independent way to do the following (modeled after Monitor.Wait and Monitor.Pulse):
Wait - temporarily allow queued Acquire and TryAcquire calls to proceed while waiting for a pulse, blocking the caller until any ISyncScope(s) acquired while waiting are disposed and at least one Pulse has occurred.
Pulse - flag to, once the ISyncScope is disposed, notify any blocking Wait calls that something changed, allowing them to proceed.
WaitAsync - return an awaitable interface that allows other Acquire and TryAcquire calls to proceed while waiting for a pulse. When a pulse is received, the continuation would be called asynchronously in a manner consistent with the behavior of Wait (TBD).