Module: Bran::LibUV::FFI

Extended by:
FFI::Library
Defined in:
lib/bran/libuv/ffi.rb

Constant Summary collapse

UV_READABLE =
1
UV_WRITABLE =
2

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.uv_poll_cb(&block) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/bran/libuv/ffi.rb', line 53

def self.uv_poll_cb(&block)
  #        (handle,   status, events)
  params = [:pointer, :int,   :int]
  ::FFI::Function.new :void, params, blocking: true do |*args|
    block.call(*args)
  end
end

.uv_signal_cb(&block) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/bran/libuv/ffi.rb', line 62

def self.uv_signal_cb(&block)
  #        (handle,   signo)
  params = [:pointer, :int]
  ::FFI::Function.new :void, params, blocking: true do |*args|
    block.call(*args)
  end
end

.uv_timer_cb(&block) ⇒ Object



71
72
73
74
75
76
77
# File 'lib/bran/libuv/ffi.rb', line 71

def self.uv_timer_cb(&block)
  #        (handle)
  params = [:pointer]
  ::FFI::Function.new :void, params, blocking: true do |*args|
    block.call(*args)
  end
end

Instance Method Details

#pointerObject

Callback factory methods.

WARNING: If your Ruby code doesn’t retain a reference to the

FFI::Function object after passing it to a C function call,
it may be garbage collected while C still holds the pointer,
potentially resulting in a segmentation fault.


52
# File 'lib/bran/libuv/ffi.rb', line 52

typedef :pointer, :uv_poll_cb_ptr