I have a launch {}, which inside i execute some bl...
# coroutines
g
I have a launch {}, which inside i execute some blocking code which is listening for a single message from a pipe. Is there a way to notify/wait when the code will be suspended at the moment it started listening on the pipe? Thanks in advance for any help.
join() will wait forever so i cant use that.
Probably i need something that notifies when code is suspended?
f
Your code is not suspended, it is blocked. There is no way of knowing when you're code is blocked AFAIK. What you can do, is to notifiy the part interested in knowing when the pipe is being listened right before you start listening to it (with a completabledeferred, a channel, a mutablestateflow, it doesn't reallt matter), but this will not guarantee that the pipe is actually being listened, you will have race condition. If I find myself needing this information, I question the design. Why do you need this information? Can you achieve what you want in an other way?