louiscad
12/13/2017, 8:00 AMGate
class on which I'd have the following methods:
- non suspending lock()
which I'd call when the connection is suspended
- non suspending unlock()
which I'd call when the connection is reestablished
- passThroughWhenUnlocked()
that would suspend if the Gate
instance is locked, and would resume when unLock()
is called. This should allow multiple suspension points
Is there something like this that exists, and if not, how could I make a class with this behavior?
EDIT: The closest I found in the kotlinx.coroutines reference is Mutex
which I can hijack with no-op lock then unlocks for the "pass through", and lock for long when the connection is suspended, until it is restored.