Is it possible to wake a process externally in Erlang after it has been sent to sleep for infinity?
I would like to wake it from a different process which does hold the process ID of the process which is asleep.
I used this within the process which I want to sleep:
timer:sleep(infinity)
If it is not possible to wake it externally, what other options are available to me?
Rather than using timer:sleep/1
, put the process into a receive
so that it waits for a message. When the other process wants it to proceed, it can simply send it a message. Assuming the message matches what the receive
is looking for, the first process will then exit the receive
and continue.
From the source code of this function:
-spec sleep(Time) -> 'ok' when
Time :: timeout().
sleep(T) ->
receive
after T -> ok
end.
you can find that sleep
just let the process wait, do nothing.
if you want wake the process, you need send message to the sleeping process and do receive
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With