Mutex implementation question

Thanks for taking a look at this!

I managed to implement a rw mutex and a semaphore but I didn’t include any stack overflow avoidance. Is it possible to somehow pull this stack overflow avoidance into the language and out of library design?

For now, I can just try to avoid using Unconfined entirely, but I noticed that some library functions that I want to use have Unconfined as the default context (e.g. ReceiveChannel.takeWhile from Channels.kt).

Can the problem be reproduced with application code that doesn’t explicitly mention “Unconfined”? If so I’m basically forced to figure out the stack overflow avoidance.