Module: Bowline::Desktop::Runtime
- Defined in:
- lib/bowline/desktop/runtime.rb
Class Method Summary collapse
-
.main(method = nil, &block) ⇒ Object
Run block/method in main thread.
- .main_thread? ⇒ Boolean
- .poll ⇒ Object
- .procs ⇒ Object
-
.setup! ⇒ Object
:nodoc:.
Class Method Details
.main(method = nil, &block) ⇒ Object
Run block/method in main thread
12 13 14 15 16 17 18 19 |
# File 'lib/bowline/desktop/runtime.rb', line 12 def main(method = nil, &block) proc = method||block if main_thread? proc.call else procs << proc end end |
.main_thread? ⇒ Boolean
22 23 24 |
# File 'lib/bowline/desktop/runtime.rb', line 22 def main_thread? Thread.current == Thread.main end |
.poll ⇒ Object
28 29 30 31 32 |
# File 'lib/bowline/desktop/runtime.rb', line 28 def poll while proc = procs.shift proc.call end end |
.procs ⇒ Object
35 36 37 |
# File 'lib/bowline/desktop/runtime.rb', line 35 def procs @procs ||= [] end |