Motivation:
Whilst investigating deadlocking code elsewhere we discovered that
resuming a continuation inside a lock can call deadlocks.
The reason is that
- `withTaskCancellationHandler` takes a sequence's
underlying runtime lock then executes the cancellation handler.
- The task cancellation handler then does work which requires taking the
NIO-level lock
- If a NIO method on a separate thread then takes the NIO-level lock and
within it resumes a continuation e.g. in `yield` we will deadlock
because the resumption attempts to obtain the underlying runtime lock.
Modifications:
Do not resume continuations within locks.
Result:
Fewer deadlock opportunities