Event

class
Superclass
Object

Represents an event returned by {CZTop::Poller#wait}.

Constants

POLL_EVENTS

Poll events in bitwise order

Attributes

reactor[R]

The CZTop::Reactor that generated this event

Public Class Methods

anchor
new( reactor, event_ptr )

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

Public Instance Methods

anchor
inspect()

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
anchor
poll_events()

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
anchor
readable?()

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
anchor
socket()

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
anchor
writable?()

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