Class: Andromeda::Impl::Atom
- Includes:
- To_S
- Defined in:
- lib/andromeda/atom.rb,
lib/andromeda/impl/atom.rb
Direct Known Subclasses
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #full? ⇒ Boolean
-
#initialize(init_val = nil) ⇒ Atom
constructor
A new instance of Atom.
- #to_short_s ⇒ Object
- #wait_until_empty? ⇒ Boolean
- #wait_until_eq(val = nil) ⇒ Object
- #wait_until_full? ⇒ Boolean
- #wait_until_ne(val = nil) ⇒ Object
- #wait_while(&test) ⇒ Object
- #with_value ⇒ Object
Methods included from To_S
Constructor Details
#initialize(init_val = nil) ⇒ Atom
Returns a new instance of Atom.
8 9 10 |
# File 'lib/andromeda/atom.rb', line 8 def initialize(init_val = nil) super init_val end |
Instance Method Details
#empty? ⇒ Boolean
12 |
# File 'lib/andromeda/atom.rb', line 12 def empty? ; value.nil? end |
#full? ⇒ Boolean
13 |
# File 'lib/andromeda/atom.rb', line 13 def full? ; ! value.nil? end |
#to_short_s ⇒ Object
15 |
# File 'lib/andromeda/atom.rb', line 15 def to_short_s ; "(#{To_S.short_s(value)})" end |
#wait_until_empty? ⇒ Boolean
32 33 34 |
# File 'lib/andromeda/atom.rb', line 32 def wait_until_empty? wait_until_eq nil end |
#wait_until_eq(val = nil) ⇒ Object
22 23 24 25 |
# File 'lib/andromeda/atom.rb', line 22 def wait_until_eq(val = nil) raise ArgumentError unless val.kind_of?(Fixnum) wait_while { |v| v != val } end |
#wait_until_full? ⇒ Boolean
36 37 38 |
# File 'lib/andromeda/atom.rb', line 36 def wait_until_full? wait_until_ne nil end |
#wait_until_ne(val = nil) ⇒ Object
27 28 29 30 |
# File 'lib/andromeda/atom.rb', line 27 def wait_until_ne(val = nil) raise ArgumentError unless val.kind_of?(Fixnum) wait_while { |v| v == val } end |
#wait_while(&test) ⇒ Object
18 19 20 |
# File 'lib/andromeda/atom.rb', line 18 def wait_while(&test) while test.call(value) ; Thread::pass end end |
#with_value ⇒ Object
40 41 42 |
# File 'lib/andromeda/atom.rb', line 40 def with_value update { |v| yield v ; v } end |