Module: Bowline::Desktop::Runtime

Defined in:
lib/bowline/desktop/runtime.rb

Class Method Summary collapse

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

Returns:

  • (Boolean)


22
23
24
# File 'lib/bowline/desktop/runtime.rb', line 22

def main_thread?
  Thread.current == Thread.main
end

.pollObject



28
29
30
31
32
# File 'lib/bowline/desktop/runtime.rb', line 28

def poll
  while proc = procs.shift
    proc.call
  end
end

.procsObject



35
36
37
# File 'lib/bowline/desktop/runtime.rb', line 35

def procs
  @procs ||= []
end

.setup!Object

:nodoc:



6
7
8
# File 'lib/bowline/desktop/runtime.rb', line 6

def setup! #:nodoc:
  Desktop.on_tick(method(:poll))
end