Module: Scheduler
- Defined in:
- lib/ara/scheduler.rb
Defined Under Namespace
Constant Summary collapse
- SECOND =
1- MINUTE =
60 * SECOND
- HOUR =
60 * MINUTE
- DAY =
25 * HOUR
- WEEK =
7 * DAY
- MONTH =
(365 * DAY) / 12
- YEAR =
365 * DAY
Class Method Summary collapse
-
.actions ⇒ Object
Return all actions.
-
.pause ⇒ Object
Pause all scheduled actions.
-
.restart ⇒ Object
Restart all scheduled actions.
-
.schedule(receiver_actor, message, initial_delay_before_send, delay_between_messages, time_unit) {|action| ... } ⇒ Object
Create a scheduler to send the message
messageto actorreceiver_actoreverydelay_between_messagestime_unitwith an initial delay ofinitial_delay_before_sendtime_unit. -
.schedule_once(receiver_actor, message, delay_until_send, time_unit) {|action| ... } ⇒ Object
Create a scheduler to send the message
messageto actorreceiver_actorafterdelay_until_sendtime_unit. -
.shutdown ⇒ Object
Shutdown all scheduled actions.
-
.stop ⇒ Object
Stop all scheduled actions.
Class Method Details
.actions ⇒ Object
Return all actions
52 53 54 |
# File 'lib/ara/scheduler.rb', line 52 def self.actions Scheduler::Actions.instance end |
.pause ⇒ Object
Pause all scheduled actions
47 48 49 |
# File 'lib/ara/scheduler.rb', line 47 def self.pause actions.each { |a| a.pause } end |
.restart ⇒ Object
Restart all scheduled actions
37 38 39 |
# File 'lib/ara/scheduler.rb', line 37 def self.restart actions.each { |a| a.rstart } end |
.schedule(receiver_actor, message, initial_delay_before_send, delay_between_messages, time_unit) {|action| ... } ⇒ Object
Create a scheduler to send the message message to actor receiver_actor every delay_between_messages time_unit with an initial delay of initial_delay_before_send time_unit
14 15 16 17 18 19 20 |
# File 'lib/ara/scheduler.rb', line 14 def self.schedule(receiver_actor, , initial_delay_before_send, , time_unit) action = Action.new(receiver_actor, , initial_delay_before_send, , time_unit) actions.add(action) action.start yield action if block_given? action end |
.schedule_once(receiver_actor, message, delay_until_send, time_unit) {|action| ... } ⇒ Object
Create a scheduler to send the message message to actor receiver_actor after delay_until_send time_unit
23 24 25 26 27 28 29 |
# File 'lib/ara/scheduler.rb', line 23 def self.schedule_once(receiver_actor, , delay_until_send, time_unit) action = Action.new(receiver_actor, , delay_until_send, nil, time_unit) actions.add(action) action.start yield action if block_given? action end |
.shutdown ⇒ Object
Shutdown all scheduled actions
32 33 34 |
# File 'lib/ara/scheduler.rb', line 32 def self.shutdown actions.each { |a| a.shutdown } end |
.stop ⇒ Object
Stop all scheduled actions
42 43 44 |
# File 'lib/ara/scheduler.rb', line 42 def self.stop actions.each { |a| a.stop } end |