Class: ActiveUsage::Worker
- Inherits:
-
Object
- Object
- ActiveUsage::Worker
- Defined in:
- lib/active_usage/worker.rb
Instance Method Summary collapse
-
#initialize(interval, &block) ⇒ Worker
constructor
A new instance of Worker.
- #join(timeout) ⇒ Object
- #stop! ⇒ Object
Constructor Details
#initialize(interval, &block) ⇒ Worker
Returns a new instance of Worker.
5 6 7 8 9 10 11 |
# File 'lib/active_usage/worker.rb', line 5 def initialize(interval, &block) @interval = interval @block = block @mutex = Mutex.new @running = true start! end |
Instance Method Details
#join(timeout) ⇒ Object
17 18 19 |
# File 'lib/active_usage/worker.rb', line 17 def join(timeout) @thread&.join(timeout) end |
#stop! ⇒ Object
13 14 15 |
# File 'lib/active_usage/worker.rb', line 13 def stop! @mutex.synchronize { @running = false } end |