Coro::Timer - simple timer package, independent of used event loops
use Coro::Timer;
This package implements a simple timer callback system which works independent of the event loop mechanism used. If no event mechanism is used, it is emulated. The Coro::Event module overwrites functions with versions better suited.
Coro::Event
This module is not subclassable.
This function will wake up the current coroutine after $seconds seconds and sets $flag to true (it is false intiially). If $flag goes out of scope earlier nothing happens. This is used to implement the timed_down, timed_wait etc. primitives. It is used like this:
timed_down
timed_wait
sub timed_wait { my $timeout = Coro::Timer::timeout 60; while (condition false) { schedule; # wait until woken up or timeout return 0 if $timeout; # timed out } return 1; # condition satisfied }
This function works like the built-in sleep, except maybe more precise and, most important, without blocking other coroutines.
Create a new timer.
Cancel the timer (the callback will no longer be called).
Marc Lehmann <pcg@goof.com> http://www.goof.com/pcg/marc/
To install Coro, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Coro
CPAN shell
perl -MCPAN -e shell install Coro
For more information on module installation, please visit the detailed CPAN module installation guide.