.true if waiting for the event semaphore to get posted has been
successful or the semaphore is already in the posted state,
and .false if a timeout occurred while waiting.
wait suspends the current activity
until the semaphore gets posted.
wait suspends the current activity for
timeout seconds or until the semaphore
gets posted, whatever comes first.
event = .EventSemaphore~new
say "main starts tasks"
do nr = 1 to 5
.task~new~waitFor(event, "task" nr)
end
call SysSleep 0.1
say "main posts"
event~post
say "main ends"
::class Task
::method waitFor
reply
use strict arg event, name
say name "waits"
event~wait
say name "runs"
main starts tasks task 2 waits task 5 waits task 1 waits task 3 waits task 4 waits main posts main ends task 4 runs task 3 runs task 1 runs task 2 runs task 5 runs