Class: Libuv::Async
- Inherits:
-
Handle
- Object
- Q::Promise
- Q::DeferredPromise
- Handle
- Libuv::Async
- Defined in:
- lib/libuv/async.rb
Constant Summary
Constants included from Assertions
Libuv::Assertions::MSG_NO_PROC
Constants inherited from Q::Promise
Instance Attribute Summary
Attributes inherited from Handle
Attributes inherited from Q::Promise
Instance Method Summary collapse
-
#call ⇒ Object
Triggers a notify event, calling everything in the notify chain.
-
#initialize(reactor, callback = nil, &blk) ⇒ Async
constructor
A new instance of Async.
-
#progress(callback = nil, &blk) ⇒ Object
Used to update the callback that will be triggered when async is called.
Methods inherited from Handle
#active?, #close, #closed?, #closing?, #ref, #unref
Methods included from Assertions
#assert_block, #assert_boolean, #assert_type
Methods included from Resource
#check_result, #check_result!, #resolve, #to_ptr
Methods inherited from Q::DeferredPromise
Methods inherited from Q::Promise
#catch, #finally, #ruby_catch, #value
Constructor Details
#initialize(reactor, callback = nil, &blk) ⇒ Async
Returns a new instance of Async.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/libuv/async.rb', line 11 def initialize(reactor, callback = nil, &blk) @reactor = reactor @callback = callback || blk async_ptr = ::Libuv::Ext.allocate_handle_async on_async = callback(:on_async, async_ptr.address) error = check_result(::Libuv::Ext.async_init(reactor.handle, async_ptr, on_async)) super(async_ptr, error) end |
Instance Method Details
#call ⇒ Object
Triggers a notify event, calling everything in the notify chain
23 24 25 26 27 28 |
# File 'lib/libuv/async.rb', line 23 def call return if @closed error = check_result ::Libuv::Ext.async_send(handle) reject(error) if error self end |
#progress(callback = nil, &blk) ⇒ Object
Used to update the callback that will be triggered when async is called
33 34 35 36 |
# File 'lib/libuv/async.rb', line 33 def progress(callback = nil, &blk) @callback = callback || blk self end |