how to find remaining time on a timer?

Fulko Hew fulko.hew at gmail.com
Thu Nov 28 16:30:41 CET 2013


I have a scenario where I need to find out how much time
is remaining on a timer (so that I can perform some calculation
and then re-schedule something, based on that calculation).

How can I find out something about the timer?
Either when it was started, how much time has elapsed,
or how much time is remaining?

I tried the following test (based on what I read about EV)
without success.

use AnyEvent;

    # make a long timer, and a short timer that can 'look into'
    # the long timer to see what it can see

my $long = AnyEvent->timer(
                after   => 5,
                cb      => sub { print "long timer done\n"; exit; }
                );
my $short = AnyEvent->timer(
                after   => 2,
                cb      => sub {
                            print "time info part way through is: ",
                                    $long->at, "\n";
                            }
                );

my $cv = AnyEvent->condvar;
$cv->wait;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/anyevent/attachments/20131128/2565f061/attachment.html>


More information about the anyevent mailing list