Sha256: 590ff512ccb17838577afbf3c2793bb8d6728bc5d082beebe2ddccd8f97b0465
Contents?: true
Size: 1.35 KB
Versions: 5
Compression:
Stored size: 1.35 KB
Contents
module Libuv class Check < Handle # @param loop [::Libuv::Loop] loop this check will be associated # @param callback [Proc] callback to be called on loop check def initialize(loop, callback = nil, &blk) @loop = loop @callback = callback || blk check_ptr = ::Libuv::Ext.create_handle(:uv_check) error = check_result(::Libuv::Ext.check_init(loop.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 end # Disables the check handler. def stop return if @closed error = check_result ::Libuv::Ext.check_stop(handle) reject(error) if error end # Used to update the callback that will be triggered on loop check # # @param callback [Proc] the callback to be called on loop check def progress(callback = nil, &blk) @callback = callback || blk end private def on_check(handle) begin @callback.call rescue Exception => e @loop.log :error, :check_cb, e end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
libuv-1.0.3 | lib/libuv/check.rb |
libuv-1.0.2 | lib/libuv/check.rb |
libuv-1.0.0 | lib/libuv/check.rb |
libuv-0.12.4 | lib/libuv/check.rb |
libuv-0.12.3 | lib/libuv/check.rb |