Class: Libuv::Check

Inherits:
Handle show all
Defined in:
lib/libuv/check.rb

Constant Summary

Constants included from Assertions

Assertions::MSG_NO_PROC

Instance Attribute Summary

Attributes inherited from Handle

#closed, #reactor, #storage

Attributes inherited from Q::Promise

#trace

Instance Method Summary collapse

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

#resolved?, #then

Methods inherited from Q::Promise

#catch, #finally, #ruby_catch, #value

Constructor Details

#initialize(reactor) ⇒ Check

Returns a new instance of Check.

Parameters:

  • reactor (::Libuv::Reactor)

    reactor this check will be associated

  • callback (Proc)

    callback to be called on reactor check



12
13
14
15
16
17
18
19
# File 'lib/libuv/check.rb', line 12

def initialize(reactor)
    @reactor = reactor

    check_ptr = ::Libuv::Ext.allocate_handle_check
    error = check_result(::Libuv::Ext.check_init(reactor.handle, check_ptr))

    super(check_ptr, error)
end

Instance Method Details

#progress(&callback) ⇒ Object

Used to update the callback that will be triggered on reactor check

Parameters:

  • callback (Proc)

    the callback to be called on reactor check



40
41
42
43
# File 'lib/libuv/check.rb', line 40

def progress(&callback)
    @callback = callback
    self
end

#startObject

Enables the check handler.



22
23
24
25
26
27
# File 'lib/libuv/check.rb', line 22

def start
    return if @closed
    error = check_result ::Libuv::Ext.check_start(handle, callback(:on_check))
    reject(error) if error
    self
end

#stopObject

Disables the check handler.



30
31
32
33
34
35
# File 'lib/libuv/check.rb', line 30

def stop
    return if @closed
    error = check_result ::Libuv::Ext.check_stop(handle)
    reject(error) if error
    self
end