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(exception) ⇒ Object



52
53
54
55
56
57
# File 'lib/ffi-glib/main_loop.rb', line 52

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

Instance Method Details

#run_with_thread_enablerObject Also known as: run



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

def run_with_thread_enabler
  ThreadEnabler.instance.setup_idle_handler if RUBY_ENGINE == 'ruby'
  RUNNING_LOOPS << self
  result = run_without_thread_enabler
  exception = EXCEPTIONS.shift
  RUNNING_LOOPS.pop
  raise exception if exception
  result
end