Sha256: a41966bc7df71ff6e828a5fff937ae203bb04d5b6af1ca78c1fd0ee6d0129c35
Contents?: true
Size: 1.58 KB
Versions: 6
Compression:
Stored size: 1.58 KB
Contents
# frozen_string_literal: true module Libuv class Check < Handle define_callback function: :on_check # @param reactor [::Libuv::Reactor] reactor this check will be associated # @param callback [Proc] callback to be called on reactor check def initialize(reactor, callback = nil, &blk) @reactor = reactor @callback = callback || blk check_ptr = ::Libuv::Ext.allocate_handle_check error = check_result(::Libuv::Ext.check_init(reactor.handle, check_ptr)) super(check_ptr, error) end # Enables the check handler. def start return if @closed error = check_result ::Libuv::Ext.check_start(handle, callback(:on_check)) reject(error) if error self end # Disables the check handler. def stop return if @closed error = check_result ::Libuv::Ext.check_stop(handle) reject(error) if error self end # Used to update the callback that will be triggered on reactor check # # @param callback [Proc] the callback to be called on reactor check def progress(callback = nil, &blk) @callback = callback || blk self end private def on_check(handle) @reactor.exec do begin @callback.call rescue Exception => e @reactor.log e, 'performing check callback' end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems
Version | Path |
---|---|
libuv-3.3.0 | lib/libuv/check.rb |
libuv-3.2.4 | lib/libuv/check.rb |
libuv-3.2.3 | lib/libuv/check.rb |
libuv-3.2.2 | lib/libuv/check.rb |
libuv-3.2.1 | lib/libuv/check.rb |
libuv-3.2.0 | lib/libuv/check.rb |