… | |
… | |
33 | |
33 | |
34 | BEGIN { |
34 | BEGIN { |
35 | eval "use Time::HiRes 'time'"; |
35 | eval "use Time::HiRes 'time'"; |
36 | } |
36 | } |
37 | |
37 | |
38 | $VERSION = 1.7; |
38 | $VERSION = 1.8; |
39 | @EXPORT_OK = qw(timeout sleep); |
39 | @EXPORT_OK = qw(timeout sleep); |
40 | |
40 | |
41 | =item $flag = timeout $seconds; |
41 | =item $flag = timeout $seconds; |
42 | |
42 | |
43 | This function will wake up the current coroutine after $seconds |
43 | This function will wake up the current coroutine after $seconds |
… | |
… | |
63 | my $current = $Coro::current; |
63 | my $current = $Coro::current; |
64 | $timer = _new_timer(time + $_[0], sub { |
64 | $timer = _new_timer(time + $_[0], sub { |
65 | undef $timer; # set flag |
65 | undef $timer; # set flag |
66 | $current->ready; |
66 | $current->ready; |
67 | }); |
67 | }); |
68 | bless $self, Coro::timeout::; |
68 | bless $self, 'Coro::timeout'; # weird quoting required by 5.9.3, it seems |
69 | } |
69 | } |
70 | |
70 | |
71 | package Coro::timeout; |
71 | package Coro::timeout; |
72 | |
72 | |
73 | sub bool { |
73 | sub bool { |