2007/2/24, ara.t.howard / noaa.gov <ara.t.howard / noaa.gov>:
> On Fri, 23 Feb 2007, John Mettraux wrote:
>
> > http://openwferu.rubyforge.org/scheduler.html
>
> looks very interesting!
>
> > advantage : one thread for all the tasks disadvantage : has to wake up to
> > pool its jobqueue
>
> hmmm.  is that even possible?
>
>
>      harp :~/openwferu/trunk/openwfe-ruby > cat a.rb
>      require "time"
>      require "openwfe/util/otime"
>      require "openwfe/util/scheduler"
>      include OpenWFE
>
>      scheduler = Scheduler.new
>
>      i = -1
>
>      scheduler.schedule('*/1 * * * *') do
>        4.times{ puts Time.now.iso8601(2); sleep 30 }  ### this takes 120s!
>        puts(i += 1)
>      end
>
>      scheduler.sstart
>
>      STDIN.gets
>
>
>
>      harp :~/openwferu/trunk/openwfe-ruby > RUBYLIB=lib ruby a.rb
>      2007-02-23T08:29:00.22-07:00
>      2007-02-23T08:29:30.22-07:00
>      2007-02-23T08:30:00.22-07:00
>      2007-02-23T08:30:30.22-07:00
>      0
> ...
>
> it seems like a single threaded/processed scheduler is an imposibility?

Hey, thanks for the light, I'll fix that / make it better.

I'll have to correct from "one thread for all tasks" to something like
"one thread as an alarm clock for all tasks".


> nevertheless i've already found a use for this code in a situation where i
> don't care if events are fired precisely (as is possible) as i declare them or
> not.

Glad to read that.


Cheers,

-- 
John Mettraux   -///-   http://jmettraux.openwfe.org