in reply to Re^5: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
in thread PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
So this is the final version of the timer code that works:
... my $w_cond = AnyEvent->condvar; $w_cond->cb( sub { warn $_[0]->recv } ); my $w; $w = AnyEvent->timer( after => 0, interval => 5, cb => sub { undef $w if (0); $session->write('5 seconds have passed'); $w_cond->send(); } ); ...
I changed undef $w; to undef $w if (0);. Now the big question is why does this work, but simply commenting out undef $w; causes the timer to not work? Is there a logical reason here, or is it voodoo? By "voodoo" I mean, code that has to be typed a certain way "just because".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: PSGI, Plack, Twiggy, AnyEvent and SockJS... I need help
by Corion (Patriarch) on Apr 09, 2014 at 17:27 UTC | |
by xtpu2 (Acolyte) on Apr 09, 2014 at 18:56 UTC | |
by Corion (Patriarch) on Apr 09, 2014 at 20:04 UTC |