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
Source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 16 def initialize(n = 0) @n = n @mutex = Monitor.new end
Public Instance Methods
Source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 68 def ==(m) @mutex.synchronize { @n == m } end
Source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 72 def ===(v) @mutex.synchronize { @n === v } end
Source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 60 def decrement @mutex.synchronize do @n = @n - 1 end end
Also aliased as: dec, decrement_and_get
Source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 21 def get @mutex.synchronize do @n end end
Also aliased as: to_i
Source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 42 def get_and_add(i) @mutex.synchronize do v = @n @n = @n + i v end end
Source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 51 def get_and_increment @mutex.synchronize do v = @n @n = @n + 1 v end end
Source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 34 def increment @mutex.synchronize do @n = @n + 1 end end
Also aliased as: inc, increment_and_get
Source
# File lib/bunny/concurrent/atomic_fixnum.rb, line 28 def set(n) @mutex.synchronize do @n = n end end