class Bunny::Concurrent::AtomicFixnum
Minimalistic implementation of a synchronized fixnum value, designed after (but not implementing the entire API of!)
@note Designed to be intentionally minimalistic and only cover Bunny’s needs.
@api public
Public Class Methods
new(n = 0)
click to toggle source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 14 def initialize(n = 0) @n = n @mutex = Monitor.new end
Public Instance Methods
==(m)
click to toggle source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 66 def ==(m) @mutex.synchronize { @n == m } end
===(v)
click to toggle source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 70 def ===(v) @mutex.synchronize { @n === v } end
decrement()
click to toggle source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 58 def decrement @mutex.synchronize do @n = @n - 1 end end
Also aliased as: dec, decrement_and_get
get()
click to toggle source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 19 def get @mutex.synchronize do @n end end
Also aliased as: to_i
get_and_add(i)
click to toggle source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 40 def get_and_add(i) @mutex.synchronize do v = @n @n = @n + i v end end
get_and_increment()
click to toggle source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 49 def get_and_increment @mutex.synchronize do v = @n @n = @n + 1 v end end
increment()
click to toggle source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 32 def increment @mutex.synchronize do @n = @n + 1 end end
Also aliased as: inc, increment_and_get
set(n)
click to toggle source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 26 def set(n) @mutex.synchronize do @n = n end end