Sha256: 41be8c9d398b3d6d8f0b21de16a3f8fa1d3301a2a88a1183739f16fa5a236180
Contents?: true
Size: 793 Bytes
Versions: 5
Compression:
Stored size: 793 Bytes
Contents
require "thread" module Bowline module Desktop module Runtime def setup! #:nodoc: Desktop.on_tick(method(:poll)) end module_function :setup! # Run block/method in main thread def main(method = nil, &block) proc = method||block if main_thread? proc.call else procs << proc end end module_function :main def main_thread? Thread.current == Thread.main end module_function :main_thread? private def poll while proc = procs.shift proc.call end end module_function :poll def procs @procs ||= [] end module_function :procs end end end
Version data entries
5 entries across 5 versions & 1 rubygems