Class: Fiber
Class Method Summary collapse
- .delete_subscription(node) ⇒ Object
- .delete_subscriptions ⇒ Object
- .set_subscription(node, value) ⇒ Object
- .sleep(timeout) ⇒ Object
- .sleep_to_next_tick ⇒ Object
- .subscribed?(node) ⇒ Boolean
- .subscription(node) ⇒ Object
- .subscriptions ⇒ Object
Instance Method Summary collapse
Class Method Details
.delete_subscription(node) ⇒ Object
56 57 58 |
# File 'lib/joffice/fiber_extensions.rb', line 56 def delete_subscription(node) subscriptions.delete(node) end |
.delete_subscriptions ⇒ Object
60 61 62 |
# File 'lib/joffice/fiber_extensions.rb', line 60 def delete_subscriptions current.subscriptions.clear end |
.set_subscription(node, value) ⇒ Object
64 65 66 |
# File 'lib/joffice/fiber_extensions.rb', line 64 def set_subscription(node, value) subscriptions[node]=value end |
.sleep(timeout) ⇒ Object
38 39 40 41 42 |
# File 'lib/joffice/fiber_extensions.rb', line 38 def sleep(timeout) f=current EventMachine::Timer.new(timeout) { f.resume } Fiber.yield end |
.sleep_to_next_tick ⇒ Object
33 34 35 36 |
# File 'lib/joffice/fiber_extensions.rb', line 33 def sleep_to_next_tick current.run_on_next_tick(nil) Fiber.yield end |
.subscribed?(node) ⇒ Boolean
52 53 54 |
# File 'lib/joffice/fiber_extensions.rb', line 52 def subscribed?(node) subscriptions.has_key?(node) end |
.subscription(node) ⇒ Object
48 49 50 |
# File 'lib/joffice/fiber_extensions.rb', line 48 def subscription(node) subscriptions[node] end |
.subscriptions ⇒ Object
44 45 46 |
# File 'lib/joffice/fiber_extensions.rb', line 44 def subscriptions current.subscriptions end |
Instance Method Details
#run_on_next_tick(value) ⇒ Object
22 23 24 25 26 |
# File 'lib/joffice/fiber_extensions.rb', line 22 def run_on_next_tick(value) EM.next_tick do resume(value) if alive? end end |
#subscriptions ⇒ Object
28 29 30 |
# File 'lib/joffice/fiber_extensions.rb', line 28 def subscriptions @subscriptions||={} end |