lib/openwfe/util/scheduler.rb in openwferu-0.9.11 vs lib/openwfe/util/scheduler.rb in openwferu-0.9.12
- old
+ new
@@ -38,11 +38,10 @@
#
# John Mettraux at openwfe.org
#
require 'monitor'
-
require 'openwfe/util/otime'
module OpenWFE
@@ -137,14 +136,20 @@
# Starts this scheduler (or restart it if it was previously stopped)
#
def sstart
@scheduler_thread = Thread.new do
+
+ if defined?(JRUBY_VERSION)
+ require 'java'
+ java.lang.Thread.current_thread.name = "openwferu scheduler (Ruby Thread)"
+ end
+
while true
break if @stopped
step
- sleep(@precision)
+ sleep @precision
end
end
end
#
@@ -295,11 +300,10 @@
#
# Returns the job id attributed to this 'cron job', this id can
# be used to unschedule the job.
#
def schedule (cron_line, params={}, &block)
-
synchronize do
params = prepare_params(params)
#
@@ -396,11 +400,10 @@
if params.is_a?(Schedulable)
params
end
def sschedule_at (at, params={}, &block)
-
synchronize do
#puts "0 at is '#{at.to_s}' (#{at.class})"
at = OpenWFE::to_ruby_time(at) \
@@ -507,10 +510,10 @@
@pending_jobs[index, 0] = job
end
#puts "push() at '#{Time.at(job.at)}'"
- return job.eid
+ job.eid
end
#
# This is the method called each time the scheduler wakes up
# (by default 4 times per second). It's meant to quickly