Class: Libvirt::Event
- Inherits:
-
Object
- Object
- Libvirt::Event
- Extended by:
- Forwardable, SingleForwardable
- Includes:
- Singleton
- Defined in:
- lib/libvirt/event.rb
Defined Under Namespace
Classes: Opaque
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
Instance Method Summary collapse
- #invoke_handle_callback(watch, fd, events, opaque) ⇒ Object
- #invoke_timeout_callback(timer, opaque) ⇒ Object
-
#register(add_handle:, update_handle:, remove_handle:, add_timer:, update_timer:, remove_timer:, schedule:) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- #registered? ⇒ Boolean
- #schedule_operation(&block) ⇒ Object
- #unregister ⇒ Object
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
22 23 24 |
# File 'lib/libvirt/event.rb', line 22 def debug @debug end |
Instance Method Details
#invoke_handle_callback(watch, fd, events, opaque) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/libvirt/event.rb', line 26 def invoke_handle_callback(watch, fd, events, opaque) cb = opaque.cb op = opaque.opaque dbg { "INVOKE_HANDLE_CALLBACK watch=#{watch} fd=#{fd} events=#{events} op=#{op}" } cb.call(watch, fd, events, op) end |
#invoke_timeout_callback(timer, opaque) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/libvirt/event.rb', line 33 def invoke_timeout_callback(timer, opaque) cb = opaque.cb op = opaque.opaque dbg { "INVOKE_TIMEOUT_CALLBACK timer=#{timer} op=#{op}" } cb.call(timer, op) end |
#register(add_handle:, update_handle:, remove_handle:, add_timer:, update_timer:, remove_timer:, schedule:) ⇒ Object
rubocop:disable Metrics/ParameterLists
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/libvirt/event.rb', line 66 def register(add_handle:, update_handle:, remove_handle:, add_timer:, update_timer:, remove_timer:, schedule:) # rubocop:disable Metrics/ParameterLists @add_handle = add_handle @update_handle = update_handle @remove_handle = remove_handle @add_timer = add_timer @update_timer = update_timer @remove_timer = remove_timer @schedule = schedule @add_handle_cb = FFI::Event.callback_function(:virEventAddHandleFunc, &method(:_add_handle)) @update_handle_cb = FFI::Event.callback_function(:virEventUpdateHandleFunc, &method(:_update_handle)) @remove_handle_cb = FFI::Event.callback_function(:virEventRemoveHandleFunc, &method(:_remove_handle)) @add_timer_cb = FFI::Event.callback_function(:virEventAddTimeoutFunc, &method(:_add_timer)) @update_timer_cb = FFI::Event.callback_function(:virEventUpdateTimeoutFunc, &method(:_update_timer)) @remove_timer_cb = FFI::Event.callback_function(:virEventRemoveTimeoutFunc, &method(:_remove_timer)) FFI::Event.virEventRegisterImpl( @add_handle_cb, @update_handle_cb, @remove_handle_cb, @add_timer_cb, @update_timer_cb, @remove_timer_cb ) @registered = true end |
#registered? ⇒ Boolean
40 41 42 |
# File 'lib/libvirt/event.rb', line 40 def registered? @registered || false end |
#schedule_operation(&block) ⇒ Object
62 63 64 |
# File 'lib/libvirt/event.rb', line 62 def schedule_operation(&block) @schedule.call(&block) end |
#unregister ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/libvirt/event.rb', line 44 def unregister @add_handle_cb = nil @update_handle_cb = nil @remove_handle_cb = nil @add_timer_cb = nil @update_timer_cb = nil @remove_timer_cb = nil @add_handle = nil @update_handle = nil @remove_handle = nil @add_timer = nil @update_timer = nil @remove_timer = nil @registered = false true end |