nkbelov
(Nikita Belov)
1
SE-0433 argues against having dedicated lock()/unlock() methods; however, this makes it unusable when interacting with withXXXContinuation (and withTaskCancellationHandler): to escape a continuation into a locked data structure, one needs to be able to write
mutex.lock()
await withCheckedContinuation { c in
array.append(c)
mutex.unlock()
}
since withLock is synchronous. Will this pattern be (potentially) possible with noncopyable guards?
cc @Alejandro
This has been discussed in the Mutex Pitch. See this message which describes the same issue, and the answers: [Pitch] Synchronous Mutual Exclusion Lock - #28 by gwendal.roue To be short: the problem is acknowledged, and there are promising future directions.
1 Like
nkbelov
(Nikita Belov)
3
Oh thanks, I was searching for this in the review thread, but for some reason not in the pitch thread 
1 Like