Quoting Peter Farmer ([EMAIL PROTECTED]):
> 
> 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.
> 
Actually this is what I would expect to happen. You yield 10 slow
events. They all get scheduled to happen at the same time, the current
one. Poor POE tries to do them, but they keep being uncooperative and
not yielding back. Everytime POE gets a look in it sees events it should
have done in the past. What should it do, the old events or the new
'now' event, your alarm? It will do the old stuff first. 

The general solution to this is be more cooperative. Be more fine
grained. Instead of this: 

foreach my $line (@lines) {
    # process $line
}

write something like this: 

sub process_line {
   # get kernel, heap, @lines could be in the heap
   if (@lines) {
        unshift $line;
        # process $line
        $kernel->yield(process_line, @lines)
   }
}

or do a few chunks at a time. 

Cheers,
-- 
Merijn Broeren | Sometime in the middle ages, God got fed up with us 
Software Geek  | and put earth at sol.milky-way.univ in his kill-file.
               | Pray all you want, it just gets junked.

Reply via email to