The complexity of this code is not due to coroutin...
# coroutines
e
The complexity of this code is not due to coroutines. It is because we are explicitly dealing with concurrency here, as we have to manage multiple concurrent invocations to get a value. Whether those concurrent invocation come from multiple threads or from multiple coroutines is a little difference to the overall code design. You just use different approach to waiting -- you park threads, but you suspend coroutines. Everything else (managing waiters and state) is the same.