Represents an event returned by {CZTop::Poller#wait}.
Poll events in bitwise order
The CZTop::Reactor that generated this event
Create a new event from the specified reactor
and
event_ptr
.
# File lib/cztop/reactor/event.rb, line 21
def initialize( reactor, event_ptr )
@reactor = reactor
@poller_event = CZTop::Poller::ZMQ::PollerEvent.new( event_ptr )
end
Return a human-readable string representation of the event suitable for debugging.
# File lib/cztop/reactor/event.rb, line 58
def inspect
return "#<%p:%#016x %p {%s}>" % [
self.class,
self.object_id * 2,
self.socket,
self.poll_events.map( &:to_s ).join( '/' )
]
end
Return the poll events this event represents.
# File lib/cztop/reactor/event.rb, line 51
def poll_events
return POLL_EVENTS.select.with_index {|ev,i| @poller_event[:events][i].nonzero? }
end
Returns true
if the event indicates the socket is readable.
# File lib/cztop/reactor/event.rb, line 39
def readable?
return @poller_event.readable?
end
Get the Socket or Actor the event corresponds to.
# File lib/cztop/reactor/event.rb, line 33
def socket
return @socket ||= self.reactor.socket_for_ptr( @poller_event[:socket] )
end
Returns true
if the event indicates the socket is writable.
# File lib/cztop/reactor/event.rb, line 45
def writable?
return @poller_event.writable?
end