Class: Libuv::Handle
- Inherits:
-
Q::DeferredPromise
- Object
- Q::Promise
- Q::DeferredPromise
- Libuv::Handle
- Includes:
- Assertions, Listener, Resource
- Defined in:
- lib/libuv/handle.rb
Constant Summary
Constants included from Assertions
Constants inherited from Q::Promise
Instance Attribute Summary collapse
-
#closed ⇒ Object
readonly
Returns the value of attribute closed.
-
#loop ⇒ Object
readonly
Returns the value of attribute loop.
-
#storage ⇒ Object
A place for general storage.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #close ⇒ Object
- #closing? ⇒ Boolean
-
#initialize(pointer, error) ⇒ Handle
constructor
A new instance of Handle.
-
#ref ⇒ Object
Public: Increment internal ref counter for the handle on the loop.
-
#unref ⇒ Object
Public: Decrement internal ref counter for the handle on the loop, useful to stop loop 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
Constructor Details
#initialize(pointer, error) ⇒ Handle
Returns a new instance of Handle.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/libuv/handle.rb', line 14 def initialize(pointer, error) @pointer = pointer @instance_id = @pointer.address # Initialise the promise super(loop, loop.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.
7 8 9 |
# File 'lib/libuv/handle.rb', line 7 def closed @closed end |
#loop ⇒ Object (readonly)
Returns the value of attribute loop.
8 9 10 |
# File 'lib/libuv/handle.rb', line 8 def loop @loop end |
#storage ⇒ Object
A place for general storage
6 7 8 |
# File 'lib/libuv/handle.rb', line 6 def storage @storage end |
Instance Method Details
#active? ⇒ Boolean
54 55 56 |
# File 'lib/libuv/handle.rb', line 54 def active? ::Libuv::Ext.is_active(handle) > 0 end |
#close ⇒ Object
48 49 50 51 52 |
# File 'lib/libuv/handle.rb', line 48 def close return if @closed @closed = true ::Libuv::Ext.close(handle, callback(:on_close)) end |
#closing? ⇒ Boolean
58 59 60 |
# File 'lib/libuv/handle.rb', line 58 def closing? ::Libuv::Ext.is_closing(handle) > 0 end |
#ref ⇒ Object
Public: Increment internal ref counter for the handle on the loop. Useful for extending the loop with custom watchers that need to make loop not stop
Returns self
34 35 36 37 |
# File 'lib/libuv/handle.rb', line 34 def ref return if @closed ::Libuv::Ext.ref(handle) end |
#unref ⇒ Object
Public: Decrement internal ref counter for the handle on the loop, useful to stop loop even when there are outstanding open handles
Returns self
43 44 45 46 |
# File 'lib/libuv/handle.rb', line 43 def unref return if @closed ::Libuv::Ext.unref(handle) end |