class ManagerScheduler
Attributes
scheduler[R]
example methods in, every, unschedule, at
Public Class Methods
new(options = nil)
click to toggle source
default constructor
Calls superclass method
ManagerBase::new
# File lib/mrpin/core/scheduler/manager_scheduler.rb, line 28 def initialize(options = nil) super(options) @scheduler = Rufus::Scheduler.new @actions = [] @actions_locker = Mutex.new end
Public Instance Methods
is_ready_for_shutdown?()
click to toggle source
# File lib/mrpin/core/scheduler/manager_scheduler.rb, line 12 def is_ready_for_shutdown? result = false @actions_locker.synchronize do result = @actions.empty? end result end
run_in_background(*actions, &action_block)
click to toggle source
# File lib/mrpin/core/scheduler/manager_scheduler.rb, line 69 def run_in_background(*actions, &action_block) @actions_locker.synchronize do actions.each do |action| @actions << action end @actions << action_block if action_block end end
start_tasks()
click to toggle source
Calls superclass method
ManagerBase#start_tasks
# File lib/mrpin/core/scheduler/manager_scheduler.rb, line 39 def start_tasks super create_background_tasks_thread nil end
Private Instance Methods
create_background_tasks_thread()
click to toggle source
# File lib/mrpin/core/scheduler/manager_scheduler.rb, line 48 def create_background_tasks_thread task = ThreadWithTask.new(0.1, 'thread_scheduler') task.run do action = nil @actions_locker.synchronize do action = @actions.shift end #synchronize next if action.nil? action.call nil end #task nil end