ExclusiveCallbackHelper
class ExclusiveCallbackHelper<T>(coroutineScope: CoroutineScope, mutex: Mutex)
Content copied to clipboard
Helper for a re-occurring pattern where we need to suspend to wait for a result of an asynchronous call and during this wait no other call is allowed to be made.
The specified mutex defines the exclusivity of the instance.
Constructors
Link copied to clipboard
fun ExclusiveCallbackHelper(coroutineScope: CoroutineScope, mutex: Mutex)
Content copied to clipboard
Functions
Link copied to clipboard
Exclusively runs the specified block then suspends until resumeIfSet is called and returns the value that was passed to that. Behavior is undefined if resumeIfSet was called when block returns false.
Link copied to clipboard
suspend fun lockAndWaitForResultCancelable(block: suspend () -> Boolean): T?
Content copied to clipboard
Exclusively runs the specified block then suspends until resumeIfSet is called and returns the value that was passed to that. Behavior is undefined if resumeIfSet was called when block returns false.
Link copied to clipboard
Resumes the suspended lockAndWaitForResult with the specified result value.