1Signal(3) User Contributed Perl Documentation Signal(3)
2
3
4
6 Coro::Signal - thread signals (binary semaphores)
7
9 use Coro;
10
11 my $sig = new Coro::Signal;
12
13 $sig->wait; # wait for signal
14
15 # ... some other "thread"
16
17 $sig->send;
18
20 This module implements signals/binary semaphores/condition variables
21 (basically all the same thing). You can wait for a signal to occur or
22 send it, in which case it will wake up one waiter, or it can be
23 broadcast, waking up all waiters.
24
25 It is recommended not to mix "send" and "broadcast" calls on the same
26 "Coro::Signal" without some deep thinking: while it should work as
27 documented, it can easily confuse you :->
28
29 You don't have to load "Coro::Signal" manually, it will be loaded
30 automatically when you "use Coro" and call the "new" constructor.
31
32 $sig = new Coro::Signal;
33 Create a new signal.
34
35 $sig->wait
36 Wait for the signal to occur (via either "send" or "broadcast").
37 Returns immediately if the signal has been sent before.
38
39 $sig->wait ($callback)
40 If you pass a callback argument to "wait", it will not wait, but
41 immediately return. The callback will be called under the same
42 conditions as "wait" without arguments would continue the thrad.
43
44 The callback might wake up any number of threads, but is NOT
45 allowed to block (switch to other threads).
46
47 $sig->send
48 Send the signal, waking up one waiting process or remember the
49 signal if no process is waiting.
50
51 $sig->broadcast
52 Send the signal, waking up all waiting process. If no process is
53 waiting the signal is lost.
54
55 $sig->awaited
56 Return true when the signal is being awaited by some process.
57
59 Marc A. Lehmann <schmorp@schmorp.de>
60 http://software.schmorp.de/pkg/Coro.html
61
62
63
64perl v5.32.0 2020-08-03 Signal(3)