class Obfusk::Atom
Attributes
_[R]
deref[R]
value[R]
Public Class Methods
new(value)
click to toggle source
new Atom
with value
# File lib/obfusk/atom.rb, line 21 def initialize(value) @mutex = Mutex.new @value = value end
Public Instance Methods
swap!(&b)
click to toggle source
atomically swaps the value to be ‘b`; uses `with_value`
# File lib/obfusk/atom.rb, line 33 def swap!(&b) with_value { |v| @value = b[v] } end
with_value(&b)
click to toggle source
calls block with value; uses a mutex to synchronize
# File lib/obfusk/atom.rb, line 27 def with_value(&b) @mutex.synchronize { b[value] } end