Sha256: 2831fb00957379618bded446df2149f94b38fc0c2a40ad7c5d5d610db1087d9e

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

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

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

require 'rubygems'
require 'fileutils'


Thread.abort_on_exception = true


#$:.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 = ! ENV['EVENTMACHINE']

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

8 entries across 8 versions & 1 rubygems

Version Path
rufus-scheduler-2.0.19 spec/spec_base.rb
rufus-scheduler-2.0.18 spec/spec_base.rb
rufus-scheduler-2.0.17 spec/spec_base.rb
rufus-scheduler-2.0.16 spec/spec_base.rb
rufus-scheduler-2.0.15 spec/spec_base.rb
rufus-scheduler-2.0.14 spec/spec_base.rb
rufus-scheduler-2.0.13 spec/spec_base.rb
rufus-scheduler-2.0.12 spec/spec_base.rb