Module: UV::Handle

Includes:
Assertions, Listener, Resource
Included in:
Async, Check, FSEvent, Idle, Prepare, Signal, Stream, Timer, UDP
Defined in:
lib/uv/handle.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Assertions

#assert_arity, #assert_block, #assert_boolean, #assert_signal, #assert_type

Methods included from Resource

#check_result, #check_result!, #to_ptr

Methods included from Listener

define_callback, undefine_callbacks

Class Method Details

.close(handle) ⇒ Object



6
7
8
# File 'lib/uv/handle.rb', line 6

def close(handle)
  proc { UV.close(handle, UV.method(:free)) }
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/uv/handle.rb', line 54

def active?
  UV.is_active(@pointer) > 0
end

#close(&block) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/uv/handle.rb', line 37

def close(&block)
  return if @pointer.nil?

  ObjectSpace.undefine_finalizer(self)

  if block
    assert_block(block)
    assert_arity(0, block)

    @close_block = block
  end

  UV.close(@pointer, callback(:on_close))

  self
end

#closing?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/uv/handle.rb', line 58

def closing?
  UV.is_closing(@pointer) > 0
end

#initialize(loop, pointer) ⇒ Object



11
12
13
14
15
# File 'lib/uv/handle.rb', line 11

def initialize(loop, pointer)
  @loop, @pointer = loop, pointer

  ObjectSpace.define_finalizer(self, Handle.close(@pointer))
end

#refObject

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



21
22
23
24
25
# File 'lib/uv/handle.rb', line 21

def ref
  UV.ref(@pointer)

  self
end

#unrefObject

Public: Decrement internal ref counter for the handle on the loop, useful to stop loop even when there are outstanding open handles

Returns self



31
32
33
34
35
# File 'lib/uv/handle.rb', line 31

def unref
  UV.unref(@pointer)

  self
end