Sha256: f1d0bd2ef08e9809e31015c9fd7a5dcf8e93dca09b5856de0919f8c5c67b286b

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 KB

Contents

#
# Specifying rufus-scheduler
#
# Fri Mar 20 22:53:33 JST 2009
#

$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))

require 'rubygems'
require 'fileutils'


#$:.unshift(File.expand_path('~/tmp/bacon/lib')) # my own bacon for a while
#require 'bacon'
#puts
#Bacon.summary_on_exit


#
# rufus/scheduler/em

# EM or plain ?

$plain = ! ARGV.include?('--em')

require 'rufus/scheduler'

if ( ! $plain)

  require 'eventmachine'

  unless (EM.reactor_running?)

    Thread.new { EM.run { } }

    sleep 0.200
    while (not EM.reactor_running?)
      Thread.pass
    end
      #
      # all this waiting, especially for the JRuby eventmachine, which seems
      # rather 'diesel'

  end
end

SCHEDULER_CLASS = $plain ?
  Rufus::Scheduler::PlainScheduler :
  Rufus::Scheduler::EmScheduler

#
# helper methods

def start_scheduler(opts={})
  SCHEDULER_CLASS.start_new(opts)
end

def stop_scheduler(s)
  #s.stop(:stop_em => true)
  #sleep 0.200 # give time to the EM to stop
  s.stop
  sleep 0.200
end

def wait_next_tick
  if defined?(EM)
    t = Thread.current
    EM.next_tick { t.wakeup }
    Thread.stop
  else
    sleep 0.500
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rufus-scheduler-2.0.11 spec/spec_base.rb
rufus-scheduler-2.0.10 spec/spec_base.rb
rufus-scheduler-2.0.9 spec/spec_base.rb
rufus-scheduler-2.0.8 spec/spec_base.rb
rufus-scheduler-2.0.7 spec/spec_base.rb