Module: Bowline::Desktop::Runtime

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

Class Method Summary (collapse)

Class Method Details

+ (Object) main(method = nil, &block)

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

+ (Boolean) main_thread?

Returns:

  • (Boolean)


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

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

+ (Object) poll



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

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

+ (Object) procs



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

def procs
  @procs ||= []
end

+ (Object) setup!

:nodoc:



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

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