Class: Andromeda::Impl::Atom

Inherits:
Atomic
  • Object
show all
Includes:
To_S
Defined in:
lib/andromeda/atom.rb,
lib/andromeda/impl/atom.rb

Direct Known Subclasses

Atom::Var

Instance Method Summary collapse

Methods included from To_S

short_s, #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

Returns:

  • (Boolean)


12
# File 'lib/andromeda/atom.rb', line 12

def empty? ; value.nil? end

#full?Boolean

Returns:

  • (Boolean)


13
# File 'lib/andromeda/atom.rb', line 13

def full? ; ! value.nil? end

#to_short_sObject



15
# File 'lib/andromeda/atom.rb', line 15

def to_short_s ; "(#{To_S.short_s(value)})" end

#wait_until_empty?Boolean

Returns:

  • (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

Raises:

  • (ArgumentError)


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

Returns:

  • (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

Raises:

  • (ArgumentError)


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_valueObject



40
41
42
# File 'lib/andromeda/atom.rb', line 40

def with_value
	update { |v| yield v ; v }
end