Class: SmartCore::Engine::Atom

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_core/engine/atom.rb

Overview

Since:

  • 0.7.0

Instance Method Summary collapse

Constructor Details

#initialize(initial_value = nil) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • initial_value (Any) (defaults to: nil)

Since:

  • 0.7.0



11
12
13
14
# File 'lib/smart_core/engine/atom.rb', line 11

def initialize(initial_value = nil)
  @value = initial_value
  @barrier = SmartCore::Engine::Lock.new
end

Instance Method Details

#swap(&block) ⇒ Any

Parameters:

  • block (Block)

Returns:

  • (Any)

Since:

  • 0.7.0



29
30
31
# File 'lib/smart_core/engine/atom.rb', line 29

def swap(&block)
  with_barrier { @value = yield(@value) }
end

#valueAny

Returns:

  • (Any)

Since:

  • 0.7.0



20
21
22
# File 'lib/smart_core/engine/atom.rb', line 20

def value
  with_barrier { @value }
end