Class: ManagerScheduler

Inherits:
ManagerBase show all
Defined in:
lib/mrpin/core/scheduler/manager_scheduler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ManagerBase

#cleanup_data, #invalidate_cache, #load_init_data, #on_data_loaded, #on_server_maintenance_on, #on_server_shutdown, #on_server_started, #start_tasks

Constructor Details

#initialize(options = nil) ⇒ ManagerScheduler

Returns a new instance of ManagerScheduler.



17
18
19
20
21
22
23
24
25
# File 'lib/mrpin/core/scheduler/manager_scheduler.rb', line 17

def initialize(options = nil)
  super(options)

  @scheduler = Rufus::Scheduler.new

  @actions = []

  @actions_locker = Mutex.new
end

Instance Attribute Details

#schedulerObject (readonly)

example methods in, every, unschedule, at



9
10
11
# File 'lib/mrpin/core/scheduler/manager_scheduler.rb', line 9

def scheduler
  @scheduler
end

Instance Method Details

#post_initObject



28
29
30
31
32
# File 'lib/mrpin/core/scheduler/manager_scheduler.rb', line 28

def post_init
  super

  create_background_tasks_thread
end

#run_in_background(*actions, &action_block) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/mrpin/core/scheduler/manager_scheduler.rb', line 56

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