Class: TimeScheduler::Counter

Inherits:
Object
  • Object
show all
Defined in:
lib/time_scheduler/scheduler.rb

Instance Method Summary collapse

Constructor Details

#initializeCounter

Returns a new instance of Counter.



183
184
185
186
# File 'lib/time_scheduler/scheduler.rb', line 183

def initialize
  @count  =  0
  @mutex  =  Mutex.new
end

Instance Method Details

#decrObject



194
195
196
197
198
199
# File 'lib/time_scheduler/scheduler.rb', line 194

def decr
  @mutex.synchronize do
    @count  -=  1    if  @count > 0
    @count
  end
end

#incrObject



188
189
190
191
192
# File 'lib/time_scheduler/scheduler.rb', line 188

def incr
  @mutex.synchronize do
    @count  +=  1
  end
end

#resetObject



201
202
203
204
205
# File 'lib/time_scheduler/scheduler.rb', line 201

def reset
  @mutex.synchronize do
    @count  =  0
  end
end