… | |
… | |
45 | # need to undef $cb because we hold references to it |
45 | # need to undef $cb because we hold references to it |
46 | $self->{cb} = undef; |
46 | $self->{cb} = undef; |
47 | %$self = (); |
47 | %$self = (); |
48 | } |
48 | } |
49 | |
49 | |
50 | sub condvar { |
|
|
51 | my $class = shift; |
|
|
52 | |
|
|
53 | bless \my $flag, $class |
|
|
54 | } |
|
|
55 | |
|
|
56 | sub broadcast { |
|
|
57 | ${$_[0]}++; |
|
|
58 | } |
|
|
59 | |
|
|
60 | sub wait { |
|
|
61 | $maincontext->iteration (1) while !${$_[0]}; |
|
|
62 | } |
|
|
63 | |
|
|
64 | sub one_event { |
50 | sub one_event { |
65 | $maincontext->iteration (1); |
51 | $maincontext->iteration (1); |
66 | } |
52 | } |
67 | |
53 | |
68 | 1 |
54 | 1 |