Class: Archfiend::ThreadLoop
- Inherits:
-
Object
- Object
- Archfiend::ThreadLoop
- Extended by:
- Forwardable
- Includes:
- SharedLoop::Runnable
- Defined in:
- lib/archfiend/thread_loop.rb
Direct Known Subclasses
Constant Summary collapse
- EXCEPTION_DELAY =
Seconds to sleep for after rescuing recoverable exception
1
Class Attribute Summary collapse
-
.subclasses ⇒ Object
readonly
Returns the value of attribute subclasses.
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
Class Method Summary collapse
-
.inherited(child_class) ⇒ Object
Collects all subclasses in the class instance variable.
- .start_all(app) ⇒ Object
Methods included from SharedLoop::Runnable
Class Attribute Details
.subclasses ⇒ Object (readonly)
Returns the value of attribute subclasses.
13 14 15 |
# File 'lib/archfiend/thread_loop.rb', line 13 def subclasses @subclasses end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
10 11 12 |
# File 'lib/archfiend/thread_loop.rb', line 10 def app @app end |
Class Method Details
.inherited(child_class) ⇒ Object
Collects all subclasses in the class instance variable
16 17 18 19 |
# File 'lib/archfiend/thread_loop.rb', line 16 def inherited(child_class) @subclasses ||= [] @subclasses.push(child_class) end |
.start_all(app) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/archfiend/thread_loop.rb', line 21 def start_all(app) (subclasses || []).map do |thread_loop_class| th = Thread.new do instance = thread_loop_class.new instance.app = app app.logger.info "Starting thread #{thread_loop_class}" instance.run end th[:name] = thread_loop_class.name th end end |