Class: GLib::MainLoop::ThreadEnabler
- Inherits:
-
Object
- Object
- GLib::MainLoop::ThreadEnabler
- 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
-
#initialize(timeout = DEFAULT_TIMEOUT) ⇒ ThreadEnabler
constructor
A new instance of ThreadEnabler.
- #setup_idle_handler ⇒ Object
Constructor Details
#initialize(timeout = DEFAULT_TIMEOUT) ⇒ ThreadEnabler
Returns a new instance of ThreadEnabler.
16 17 18 |
# File 'lib/ffi-glib/main_loop.rb', line 16 def initialize(timeout = DEFAULT_TIMEOUT) @timeout = timeout end |
Instance Method Details
#setup_idle_handler ⇒ Object
20 21 22 23 |
# File 'lib/ffi-glib/main_loop.rb', line 20 def setup_idle_handler @handler_id ||= GLib.timeout_add(GLib::PRIORITY_DEFAULT, @timeout, &handler_proc) end |