Class: Raktr::Tasks
- Inherits:
-
Object
- Object
- Raktr::Tasks
- Includes:
- Mutex_m
- Defined in:
- lib/raktr/tasks.rb,
lib/raktr/tasks/base.rb,
lib/raktr/tasks/delayed.rb,
lib/raktr/tasks/one_off.rb,
lib/raktr/tasks/periodic.rb,
lib/raktr/tasks/persistent.rb
Overview
Task list.
Defined Under Namespace
Classes: Base, Delayed, OneOff, Periodic, Persistent
Instance Method Summary collapse
-
#<<(task) ⇒ Tasks
‘self`.
- #any? ⇒ Bool
-
#call(*args) ⇒ Tasks
Calls all tasks.
-
#clear ⇒ Tasks
Removes all tasks.
-
#delete(task) ⇒ Base?
The task if it was included, ‘nil` otherwise.
- #empty? ⇒ Bool
- #hash ⇒ Object
- #include?(task) ⇒ Bool
-
#initialize ⇒ Tasks
constructor
A new instance of Tasks.
- #size ⇒ Integer
Constructor Details
#initialize ⇒ Tasks
Returns a new instance of Tasks.
25 26 27 28 29 |
# File 'lib/raktr/tasks.rb', line 25 def initialize super @tasks = [] end |
Instance Method Details
#<<(task) ⇒ Tasks
37 38 39 40 41 42 43 44 |
# File 'lib/raktr/tasks.rb', line 37 def <<( task ) synchronize do task.owner = self @tasks << task end self end |
#any? ⇒ Bool
76 77 78 |
# File 'lib/raktr/tasks.rb', line 76 def any? !empty? end |
#call(*args) ⇒ Tasks
Calls all tasks.
94 95 96 97 |
# File 'lib/raktr/tasks.rb', line 94 def call( *args ) @tasks.dup.each { |t| t.call *args } self end |
#clear ⇒ Tasks
Removes all tasks.
83 84 85 86 87 88 89 |
# File 'lib/raktr/tasks.rb', line 83 def clear synchronize do @tasks.clear end self end |
#delete(task) ⇒ Base?
Returns The task if it was included, ‘nil` otherwise.
57 58 59 60 61 62 63 |
# File 'lib/raktr/tasks.rb', line 57 def delete( task ) synchronize do task = @tasks.delete( task ) task.owner = nil if task task end end |
#empty? ⇒ Bool
71 72 73 |
# File 'lib/raktr/tasks.rb', line 71 def empty? @tasks.empty? end |
#hash ⇒ Object
99 100 101 |
# File 'lib/raktr/tasks.rb', line 99 def hash @tasks.hash end |
#include?(task) ⇒ Bool
49 50 51 |
# File 'lib/raktr/tasks.rb', line 49 def include?( task ) @tasks.include? task end |
#size ⇒ Integer
66 67 68 |
# File 'lib/raktr/tasks.rb', line 66 def size @tasks.size end |