Class: StatsThread
- Inherits:
-
Object
- Object
- StatsThread
- Defined in:
- lib/yodel/task_queue/stats_thread.rb
Constant Summary collapse
- PERIOD =
60
Instance Method Summary collapse
-
#initialize ⇒ StatsThread
constructor
A new instance of StatsThread.
- #kill ⇒ Object
- #processed_task ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize ⇒ StatsThread
Returns a new instance of StatsThread.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/yodel/task_queue/stats_thread.rb', line 4 def initialize @processed = 0 @running = true Thread.new do while @running sleep(PERIOD) puts "Processed #{@processed} tasks" @processed = 0 end end end |
Instance Method Details
#kill ⇒ Object
20 21 22 |
# File 'lib/yodel/task_queue/stats_thread.rb', line 20 def kill @thread.kill end |
#processed_task ⇒ Object
24 25 26 |
# File 'lib/yodel/task_queue/stats_thread.rb', line 24 def processed_task @processed += 1 end |
#stop ⇒ Object
16 17 18 |
# File 'lib/yodel/task_queue/stats_thread.rb', line 16 def stop @running = false end |