gants has asked for the wisdom of the Perl Monks concerning the following question:

hi, how I can make priority scheduler on perl? e.g. I've data flow and need queueing this by different priorites(timeouts), i.e. if something was matched it must be inherent on specify timer issue, but timer can be flushed if happening external influence(while log-file reading would be read a new value related with this timer queue)
my $priority; again: $priority->{$thing}->{$index}->{timer} = $timer; # $time are external +value #and then check this out... if($priority->{$thing}->{$index}->{timer} < 1000){ #enqueued by wait and then again check accepted new external value $priority->{$thing}->{$index}->{wait} = $priority->{$thing}->{$index}- +>{wait} + 100; ... goto again; # how this make not blocked? }else{ do_smth(); }
in another words I need wait if some timer of those $thing and $index until 1000 and do than non-blocked, because if I would do this by blocked way it must be ugly and idea with queues brought a fiasco. in conclude my aim is to do queuing matched patterns coming from flow of the data in one thread.

Replies are listed 'Best First'.
Re: scheduling prioriting
by moritz (Cardinal) on Oct 28, 2009 at 11:22 UTC
    Maybe something like POE can help you?
    Perl 6 - links to (nearly) everything that is Perl 6.
Re: scheduling prioriting
by gmargo (Hermit) on Oct 28, 2009 at 13:26 UTC

    If your goal is to listen for several inputs simultaneously, without blocking, perhaps you can use IO::Poll or IO::Select.

      >If your goal is to listen for several inputs simultaneously, without blocking, perhaps you can use IO::Poll or IO::Select.

      yes, I use select for waiting data appearing into the file, it's look like a watch dog. but values must be different and then I want to do this priorities. for instance if I've got 20 and 60, second bigger then first, also for second must be assigned less timeout then for first value.