Class: Sideband::Thread
- Inherits:
-
Object
- Object
- Sideband::Thread
- Defined in:
- lib/sideband/thread.rb
Instance Attribute Summary collapse
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
-
#initialize(manager) ⇒ Thread
constructor
A new instance of Thread.
- #join ⇒ Object
- #kill ⇒ Object
Constructor Details
#initialize(manager) ⇒ Thread
Returns a new instance of Thread.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sideband/thread.rb', line 6 def initialize(manager) @manager = manager @thread = ::Thread.new do while @manager.queue && work = @manager.queue.pop exit if work.nil? begin work.call rescue Exception # Sideband will ignore all Exceptions, # better to handle in your workers. end end end end |
Instance Attribute Details
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
4 5 6 |
# File 'lib/sideband/thread.rb', line 4 def thread @thread end |
Instance Method Details
#join ⇒ Object
22 23 24 |
# File 'lib/sideband/thread.rb', line 22 def join thread.join end |
#kill ⇒ Object
26 27 28 |
# File 'lib/sideband/thread.rb', line 26 def kill thread.kill end |