Class: Libuv::Handle
- Inherits:
-
Q::DeferredPromise
- Object
- Q::Promise
- Q::DeferredPromise
- Libuv::Handle
- Includes:
- Assertions, Listener, Resource
- Defined in:
- lib/libuv/handle.rb
Direct Known Subclasses
Async, Check, FSEvent, Idle, Pipe, Prepare, Signal, Spawn, TCP, TTY, Timer, UDP
Constant Summary
Constants included from Assertions
Instance Attribute Summary collapse
-
#closed ⇒ Object
readonly
Returns the value of attribute closed.
-
#reactor ⇒ Object
readonly
Returns the value of attribute reactor.
-
#storage ⇒ Object
A place for general storage.
Attributes inherited from Q::Promise
Instance Method Summary collapse
- #active? ⇒ Boolean
- #close ⇒ Object
- #closed? ⇒ Boolean
- #closing? ⇒ Boolean
-
#initialize(pointer, error) ⇒ Handle
constructor
A new instance of Handle.
-
#ref ⇒ Object
Public: Increment internal ref counter for the handle on the reactor.
-
#unref ⇒ Object
Public: Decrement internal ref counter for the handle on the reactor, useful to stop reactor even when there are outstanding open handles.
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, #progress, #ruby_catch, #value
Constructor Details
#initialize(pointer, error) ⇒ Handle
Returns a new instance of Handle.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/libuv/handle.rb', line 16 def initialize(pointer, error) @pointer = pointer @instance_id = @pointer.address # Initialise the promise super(reactor, reactor.defer) # clean up on init error (always raise here) if error ::Libuv::Ext.free(pointer) defer.reject(error) @closed = true raise error end end |
Instance Attribute Details
#closed ⇒ Object (readonly)
Returns the value of attribute closed.
9 10 11 |
# File 'lib/libuv/handle.rb', line 9 def closed @closed end |
#reactor ⇒ Object (readonly)
Returns the value of attribute reactor.
10 11 12 |
# File 'lib/libuv/handle.rb', line 10 def reactor @reactor end |
#storage ⇒ Object
A place for general storage
8 9 10 |
# File 'lib/libuv/handle.rb', line 8 def storage @storage end |
Instance Method Details
#active? ⇒ Boolean
63 64 65 |
# File 'lib/libuv/handle.rb', line 63 def active? ::Libuv::Ext.is_active(handle) > 0 end |
#close ⇒ Object
52 53 54 55 56 57 |
# File 'lib/libuv/handle.rb', line 52 def close return self if @closed @closed = true ::Libuv::Ext.close(handle, callback(:on_close)) self end |
#closed? ⇒ Boolean
59 60 61 |
# File 'lib/libuv/handle.rb', line 59 def closed? !!@closed end |
#closing? ⇒ Boolean
67 68 69 |
# File 'lib/libuv/handle.rb', line 67 def closing? ::Libuv::Ext.is_closing(handle) > 0 end |
#ref ⇒ Object
Public: Increment internal ref counter for the handle on the reactor. Useful for extending the reactor with custom watchers that need to make reactor not stop
Returns self
36 37 38 39 40 |
# File 'lib/libuv/handle.rb', line 36 def ref return self if @closed ::Libuv::Ext.ref(handle) self end |