Class: CZTop::Poller::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/cztop/poller.rb

Overview

Represents an event returned by #wait. This is useful to find out whether the associated socket is now readable or writable, in case you’re interested in both. For a simpler variant, check out #simple_wait.

Instance Method Summary collapse

Constructor Details

#initialize(poller, event_ptr) ⇒ Event

Returns a new instance of Event.

Parameters:

  • poller (CZTop::Poller)

    the poller instance

  • event_ptr (FFI::Pointer)

    pointer to the memory allocated for the event’s data (a zmq_poller_event_t)



219
220
221
222
# File 'lib/cztop/poller.rb', line 219

def initialize(poller, event_ptr)
  @poller       = poller
  @poller_event = ZMQ::PollerEvent.new(event_ptr)
end

Instance Method Details

#readable?Boolean

Returns whether it’s readable.

Returns:

  • (Boolean)

    whether it’s readable



232
233
234
# File 'lib/cztop/poller.rb', line 232

def readable?
  @poller_event.readable?
end

#socketSocket, Actor

Returns the associated socket.

Returns:



226
227
228
# File 'lib/cztop/poller.rb', line 226

def socket
  @socket ||= @poller.socket_for_ptr(@poller_event[:socket])
end

#writable?Boolean

Returns whether it’s writable.

Returns:

  • (Boolean)

    whether it’s writable



238
239
240
# File 'lib/cztop/poller.rb', line 238

def writable?
  @poller_event.writable?
end