Module: Green::GreenMethods
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, val) ⇒ Object
- #kill ⇒ Object
- #locals ⇒ Object
- #schedule(*args) ⇒ Object (also: #call)
- #switch(*args) ⇒ Object
- #throw(exc = RuntimeException.new) ⇒ Object
Instance Method Details
#[](name) ⇒ Object
30 31 32 |
# File 'lib/green.rb', line 30 def [](name) locals[name] end |
#[]=(name, val) ⇒ Object
34 35 36 |
# File 'lib/green.rb', line 34 def []=(name, val) locals[name] = val end |
#locals ⇒ Object
26 27 28 |
# File 'lib/green.rb', line 26 def locals f.local_fiber_variables end |
#schedule(*args) ⇒ Object Also known as: call
38 39 40 |
# File 'lib/green.rb', line 38 def schedule(*args) Green.hub.callback { self.switch(*args) } end |
#switch(*args) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/green.rb', line 10 def switch(*args) f.transfer(*args).tap do |*res| if res.size == 1 && res.first.is_a?(ThrowException) raise(res.first.exc) end end end |
#throw(exc = RuntimeException.new) ⇒ Object
18 19 20 |
# File 'lib/green.rb', line 18 def throw(exc = RuntimeException.new) Green.hub.callback { switch(ThrowException.new exc) } end |