Sha256: 110188f3673ae28648546c0948a9313f34d84251bd69f4dc87d547ff13d05956

Contents?: true

Size: 966 Bytes

Versions: 9

Compression:

Stored size: 966 Bytes

Contents

#
# showing how to use the scheduler
#

require 'time'

require 'openwfe/util/scheduler'
include OpenWFE


def p (msg)
    t = Time.new
    puts "#{t.iso8601} -- #{msg}"
end
    #
    # a small method for displaying the time at the beginning
    # of each output line


scheduler = Scheduler.new
scheduler.start
    #
    # create a scheduler instance and start it

p "started scheduler"

scheduler.schedule_in("3s") do
    p "after 3 seconds"
end

scheduler.schedule_in("2s") do
    p "after 2 seconds"
end

scheduler.schedule_in("5500") do
    p "after 5500 ms stopping the scheduler and exiting..."
    scheduler.do_stop
end

#scheduler.schedule_at("x" do
#end

#scheduler.schedule_in("3M4h27m") do
#    p "3 months, 4 hours and 27 minutes... A bit too much"
#end
    #
    # showing what the time strings are capable of

scheduler.join
    #
    # align the thread of this program to the scheduler thread
    # i.e. exit program only when scheduler terminates

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
openwferu-0.9.10 examples/scheduler_usage.rb
openwferu-0.9.10.653 examples/scheduler_usage.rb
openwferu-0.9.3 examples/scheduler_usage.rb
openwferu-0.9.4 examples/scheduler_usage.rb
openwferu-0.9.5 examples/scheduler_usage.rb
openwferu-0.9.6 examples/scheduler_usage.rb
openwferu-0.9.7 examples/scheduler_usage.rb
openwferu-0.9.8 examples/scheduler_usage.rb
openwferu-0.9.9 examples/scheduler_usage.rb