Sha256: be5f1e401a292d724d77d2ecd2bad2b1f964ef001db3eac9b46629d275b52bcb
Contents?: true
Size: 1.14 KB
Versions: 5
Compression:
Stored size: 1.14 KB
Contents
module Libuv class Async < Handle # @param loop [::Libuv::Loop] loop this async callback will be associated def initialize(loop, callback = nil, &blk) @loop = loop @callback = callback || blk async_ptr = ::Libuv::Ext.allocate_handle_async error = check_result(::Libuv::Ext.async_init(loop.handle, async_ptr, callback(:on_async))) super(async_ptr, error) end # Triggers a notify event, calling everything in the notify chain def call return if @closed error = check_result ::Libuv::Ext.async_send(handle) reject(error) if error end # Used to update the callback that will be triggered when async is called # # @param callback [Proc] the callback to be called on loop prepare def progress(callback = nil, &blk) @callback = callback || blk end private def on_async(handle) begin @callback.call rescue Exception => e @loop.log :error, :async_cb, e end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
libuv-1.2.0 | lib/libuv/async.rb |
libuv-1.1.3 | lib/libuv/async.rb |
libuv-1.1.2 | lib/libuv/async.rb |
libuv-1.1.1 | lib/libuv/async.rb |
libuv-1.1.0 | lib/libuv/async.rb |