Class: Aerospike::Atomic

Inherits:
Object
  • Object
show all
Defined in:
lib/aerospike/atomic/atomic.rb

Overview

Container object for client policy command.

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Atomic

:nodoc:



23
24
25
26
27
# File 'lib/aerospike/atomic/atomic.rb', line 23

def initialize(value)
  @value = value

  @mutex = Mutex.new
end

Instance Method Details

#getObject Also known as: value



35
36
37
38
39
40
41
# File 'lib/aerospike/atomic/atomic.rb', line 35

def get
  ret = nil
  @mutex.synchronize do
    ret = @value
  end
  ret
end

#set(value) ⇒ Object Also known as: value=



46
47
48
49
50
# File 'lib/aerospike/atomic/atomic.rb', line 46

def set(value)
  @mutex.synchronize do
    @value = value
  end
end

#update(&block) ⇒ Object



29
30
31
32
33
# File 'lib/aerospike/atomic/atomic.rb', line 29

def update(&block)
  @mutex.synchronize do
    @value = block.call(@value)
  end
end