Class: StatsThread

Inherits:
Object
  • Object
show all
Defined in:
lib/yodel/task_queue/stats_thread.rb

Constant Summary collapse

PERIOD =
60

Instance Method Summary collapse

Constructor Details

#initializeStatsThread

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

#killObject



20
21
22
# File 'lib/yodel/task_queue/stats_thread.rb', line 20

def kill
  @thread.kill
end

#processed_taskObject



24
25
26
# File 'lib/yodel/task_queue/stats_thread.rb', line 24

def processed_task
  @processed += 1
end

#stopObject



16
17
18
# File 'lib/yodel/task_queue/stats_thread.rb', line 16

def stop
  @running = false
end