How to control main thread
MrLuer opened this issue · comments
sub threads control by the main thread, but how to control the main thread?such as, if main thread sleep for 100s , at the 32s I want the main thread quit sleep,how to implement this
lanes.sleep
Altought sleeping does not always makes sense when you are in a receive loop
See: lanes.timer
@sonoro1234 thank you for your reply
I know timer,but how timer control or wakeup main thread?
two posibilities:
-- main thread call lanes.sleep
-- main thread calls linda:receive (with or without timeout) waiting for a key that can be sent by a timer or by another thread.
The second one is what is normally done in all lanes : having a linda:receive
loop without a timeout. So that lanes are usually slepping unless they receive a key over this linda (from another lane or a timer). That way you dont think about how to make a lane sleep, but instead, how to make a lane awake: sending a key to the linda that this lane is receiving.
@sonoro1234
thank you very much, it helpful for me