Class: GLib::MainLoop::ThreadEnabler

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

Overview

Class encapsulationg logic for running an idle handler to make Ruby code run during GLib’s event loop.

Constant Summary collapse

FRAMERATE =
25
DEFAULT_TIMEOUT =
1000 / FRAMERATE

Instance Method Summary collapse

Constructor Details

#initialize(timeout = DEFAULT_TIMEOUT) ⇒ ThreadEnabler

Returns a new instance of ThreadEnabler.



18
19
20
# File 'lib/ffi-glib/main_loop.rb', line 18

def initialize(timeout = DEFAULT_TIMEOUT)
  @timeout = timeout
end

Instance Method Details

#setup_idle_handlerObject



22
23
24
25
# File 'lib/ffi-glib/main_loop.rb', line 22

def setup_idle_handler
  @handler_id ||=
    GLib.timeout_add(GLib::PRIORITY_DEFAULT, @timeout, &handler_proc)
end