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)


199
200
201
202
# File 'lib/cztop/poller.rb', line 199

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


210
211
212
# File 'lib/cztop/poller.rb', line 210

def readable?
  @poller_event.readable?
end

#socketSocket, Actor

Returns the associated socket.

Returns:


205
206
207
# File 'lib/cztop/poller.rb', line 205

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

#writable?Boolean

Returns whether it's writable.

Returns:

  • (Boolean)

    whether it's writable


215
216
217
# File 'lib/cztop/poller.rb', line 215

def writable?
  @poller_event.writable?
end