Class: Scheduler::Action
- Inherits:
-
Object
- Object
- Scheduler::Action
- Defined in:
- lib/ara/scheduler.rb
Instance Method Summary collapse
-
#initialize(receiver_actor, message, initial_delay, delay, time_unit) ⇒ Action
constructor
:nodoc:.
-
#pause ⇒ Object
Pause the action.
-
#restart ⇒ Object
Restart the action.
-
#shutdown ⇒ Object
Shutdown the action.
-
#start ⇒ Object
Start the action.
-
#stop ⇒ Object
Stop the action.
Constructor Details
#initialize(receiver_actor, message, initial_delay, delay, time_unit) ⇒ Action
:nodoc:
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ara/scheduler.rb', line 86 def initialize(receiver_actor, , initial_delay, delay, time_unit) #:nodoc: @receiver_actor = receiver_actor @message = @initial_delay = initial_delay @delay = delay @time_unit = time_unit @once = delay == nil @current_delay = @initial_delay @thread = nil end |
Instance Method Details
#pause ⇒ Object
Pause the action
121 122 123 124 |
# File 'lib/ara/scheduler.rb', line 121 def pause @thread.kill @thread = nil end |
#restart ⇒ Object
Restart the action
127 128 129 130 |
# File 'lib/ara/scheduler.rb', line 127 def restart stop unless @thread.nil? start end |
#shutdown ⇒ Object
Shutdown the action
133 134 135 136 |
# File 'lib/ara/scheduler.rb', line 133 def shutdown stop Scheduler.actions.remove(self) end |
#start ⇒ Object
Start the action
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/ara/scheduler.rb', line 100 def start return unless Scheduler.actions.include?(self) @thread = Thread.new { while(true) run @current_delay = @delay if @current_delay.nil? break end end shutdown } end |
#stop ⇒ Object
Stop the action
115 116 117 118 |
# File 'lib/ara/scheduler.rb', line 115 def stop @current_delay = @initial_delay pause end |