Class: Bob::BackgroundEngines::Threaded::ThreadPool::Incrementor

Inherits:
Object
  • Object
show all
Defined in:
lib/bob/background_engines/threaded.rb

Instance Method Summary collapse

Constructor Details

#initialize(v = 0) ⇒ Incrementor

Returns a new instance of Incrementor.



25
26
27
28
# File 'lib/bob/background_engines/threaded.rb', line 25

def initialize(v = 0)
  @m = Mutex.new
  @v = v
end

Instance Method Details

#dec(v = 1) ⇒ Object



34
35
36
# File 'lib/bob/background_engines/threaded.rb', line 34

def dec(v = 1)
  sync { @v -= v }
end

#inc(v = 1) ⇒ Object



30
31
32
# File 'lib/bob/background_engines/threaded.rb', line 30

def inc(v = 1)
  sync { @v += v }
end

#inspectObject



38
39
40
# File 'lib/bob/background_engines/threaded.rb', line 38

def inspect
  @v.inspect
end

#to_iObject



42
43
44
# File 'lib/bob/background_engines/threaded.rb', line 42

def to_i
  @v
end