Peter Farmer wrote:
Hi all,

...

Now, when I run the script, because of the
$kernel->delay_set("scheduler",10) at the end of the "sche" sub, I'm
expecting to see "sche" running at about 1149783936 or 1149783938 or
as soon as possible after the 10 seconds have passed not 1149783946
once all the other event "job_runners" are finished.

My POE version is 0.3501.

Sorry to be a pain...... :)


Hi Peter,

The problem is that you have the "right" assumption of POE but the wrong implementation. POE is a "cooperative multi-tasking" environment, which means it doesn't guarantee that events will arrive at the specific time. It processes *ALL* events in a "queue" ( we're working on having a separate thread for each session so they can REALLY run concurrently, but that's a topic for another time )

The problem here is that you're using "sleep" - this forces POE to HALT everything and wait for the sleep to return. Hence the 'cooperative' part - POE expects you to give control back to it as soon as possible. You can greatly improve your script simply by changing the sleep(2) to a timed event. However, the other suggestions I've seen on the list makes more sense - the FollowTail example, for one.

If you want to see exactly what you are thinking, simply remove the 10+ yields for job_runner and replace the sleep() call with a delay_set( 'job_runner', 2 ). This will not exactly achieve what your program's general logic wants to do, but it's a step in the right direction :)

Good luck and welcome to the magnificent world of POE!

--
Apocalypse

Homepage:       http://JiNxEdStAr.0ne.us
IRC:            [EMAIL PROTECTED]
IRC:            [EMAIL PROTECTED]
Perl Stuff:     http://search.cpan.org/~APOCAL/

Reply via email to