Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: POE::Session - why does alarm order matter?

by jfroebe (Vicar)
on Jul 02, 2008 at 02:14 UTC ( #695068=note: print w/ replies, xml ) Need Help??


in reply to Re: POE::Session - why does alarm order matter?
in thread POE::Session - why does alarm order matter?

Thanks! It's clear now :) I added alarm_remove() to remove the old alarms

Working code:

#!/usr/bin/perl use strict; use warnings; use POE; use Time::HiRes qw(time); POE::Session->create ( inline_states => { _start => sub { $_[KERNEL]->alias_set('timer'); $_[KERNEL]->post('timer', 'wakeup'); }, wakeup => sub { print "wakeup at ", scalar localtime(), "\n"; $_[KERNEL]->alarm_remove( $_[HEAP]{wakeup_alarm_id} ) if $ +_[HEAP]{wakeup_alarm_id}; $_[HEAP]{wakeup_alarm_id} = $_[KERNEL]->alarm_add( wakeup +=> int( time() ) + 2 ); $_[HEAP]{wokeup_alarm_id} = $_[KERNEL]->alarm_add( wokeup +=> int( time() ) + 2 ); }, wokeup => sub { $_[KERNEL]->alarm_remove( $_[HEAP]{wokeup_alarm_id} ) if $ +_[HEAP]{wokeup_alarm_id}; print "wokeup at ", scalar localtime(), "\n"; }, }, ); POE::Kernel->run(); exit 0;

Jason L. Froebe

Blog, Tech Blog


Comment on Re^2: POE::Session - why does alarm order matter?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://695068]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-09-01 13:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (10 votes), past polls