Class: GLib::MainLoop

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi-glib/main_loop.rb

Overview

Overrides for GMainLoop, GLib’s event loop

Defined Under Namespace

Classes: ThreadEnabler

Constant Summary collapse

EXCEPTIONS =
[]
RUNNING_LOOPS =
[]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.handle_exception(ex) ⇒ Object



56
57
58
59
60
61
# File 'lib/ffi-glib/main_loop.rb', line 56

def self.handle_exception(ex)
  current_loop = RUNNING_LOOPS.last
  raise ex unless current_loop
  EXCEPTIONS << ex
  current_loop.quit
end

Instance Method Details

#run_with_thread_enablerObject Also known as: run



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ffi-glib/main_loop.rb', line 41

def run_with_thread_enabler
  case RUBY_ENGINE
  when 'jruby'
  when 'rbx'
  else # 'ruby' most likely
    ThreadEnabler.instance.setup_idle_handler
  end
  RUNNING_LOOPS << self
  result = run_without_thread_enabler
  ex = EXCEPTIONS.shift
  RUNNING_LOOPS.pop
  raise ex if ex
  result
end