Open Lighting Architecture  Latest Git
Public Member Functions | List of all members
ola::io::KQueuePoller Class Reference

Detailed Description

An implementation of PollerInterface that uses kevent / kqueue.

kevent is more efficient than select() but only BSD-style systems support it.

Inheritance diagram for ola::io::KQueuePoller:
Inheritance graph
[legend]
Collaboration diagram for ola::io::KQueuePoller:
Collaboration graph
[legend]

Public Member Functions

 KQueuePoller (ExportMap *export_map, Clock *clock)
 Create a new KQueuePoller. More...
 
bool AddReadDescriptor (class ReadFileDescriptor *descriptor)
 Register a ReadFileDescriptor for read events. More...
 
bool AddReadDescriptor (class ConnectedDescriptor *descriptor, bool delete_on_close)
 Register a ConnectedDescriptor for read events. More...
 
bool RemoveReadDescriptor (class ReadFileDescriptor *descriptor)
 Unregister a ReadFileDescriptor for read events. More...
 
bool RemoveReadDescriptor (class ConnectedDescriptor *descriptor)
 Unregister a ConnectedDescriptor for read events. More...
 
bool AddWriteDescriptor (class WriteFileDescriptor *descriptor)
 Register a WriteFileDescriptor to receive ready-to-write events. More...
 
bool RemoveWriteDescriptor (class WriteFileDescriptor *descriptor)
 Unregister a WriteFileDescriptor for write events. More...
 
const TimeStampWakeUpTime () const
 
bool Poll (TimeoutManager *timeout_manager, const TimeInterval &poll_interval)
 Poll the Descriptors for events and execute any callbacks. More...
 
- Public Member Functions inherited from ola::io::PollerInterface
virtual ~PollerInterface ()
 Destructor.
 

Additional Inherited Members

- Static Public Attributes inherited from ola::io::PollerInterface
static const char K_READ_DESCRIPTOR_VAR [] = "ss-read-descriptors"
 The number of descriptors registered for read events.
 
static const char K_WRITE_DESCRIPTOR_VAR [] = "ss-write-descriptor"
 The number of descriptors registered for write events.
 
static const char K_CONNECTED_DESCRIPTORS_VAR []
 The number of connected descriptors registered for read events. More...
 
- Static Protected Attributes inherited from ola::io::PollerInterface
static const char K_LOOP_TIME [] = "ss-loop-time"
 The time spent in the event loop.
 
static const char K_LOOP_COUNT [] = "ss-loop-count"
 The number of iterations through the event loop.
 

Constructor & Destructor Documentation

◆ KQueuePoller()

ola::io::KQueuePoller::KQueuePoller ( ExportMap export_map,
Clock clock 
)

Create a new KQueuePoller.

Parameters
export_mapthe ExportMap to use
clockthe Clock to use

Member Function Documentation

◆ AddReadDescriptor() [1/2]

bool ola::io::KQueuePoller::AddReadDescriptor ( class ReadFileDescriptor descriptor)
virtual

Register a ReadFileDescriptor for read events.

Parameters
descriptorthe ReadFileDescriptor to register. The OnData() method will be called when there is data available for reading.
Returns
true if the descriptor was registered, false otherwise.

Implements ola::io::PollerInterface.

◆ AddReadDescriptor() [2/2]

bool ola::io::KQueuePoller::AddReadDescriptor ( class ConnectedDescriptor descriptor,
bool  delete_on_close 
)
virtual

Register a ConnectedDescriptor for read events.

Parameters
descriptorthe ConnectedDescriptor to register. The OnData() method will be called when there is data available for reading. Additionally, OnClose() will be called if the other end closes the connection.
delete_on_closecontrols whether the descriptor is deleted when it's closed.
Returns
true if the descriptor was registered, false otherwise.

Implements ola::io::PollerInterface.

◆ AddWriteDescriptor()

bool ola::io::KQueuePoller::AddWriteDescriptor ( class WriteFileDescriptor descriptor)
virtual

Register a WriteFileDescriptor to receive ready-to-write events.

Parameters
descriptorthe WriteFileDescriptor to register. The PerformWrite() method will be called when the descriptor is ready for writing.
Returns
true if the descriptor was registered, false otherwise.

Implements ola::io::PollerInterface.

◆ Poll()

bool ola::io::KQueuePoller::Poll ( TimeoutManager timeout_manager,
const TimeInterval poll_interval 
)
virtual

Poll the Descriptors for events and execute any callbacks.

Parameters
timeout_managerthe TimeoutManager to use for timer events.
poll_intervalthe maximum time to block for.
Returns
false if any errors occurred, true if events were handled.

Implements ola::io::PollerInterface.

◆ RemoveReadDescriptor() [1/2]

bool ola::io::KQueuePoller::RemoveReadDescriptor ( class ReadFileDescriptor descriptor)
virtual

Unregister a ReadFileDescriptor for read events.

Parameters
descriptorthe ReadFileDescriptor to unregister.
Returns
true if unregistered successfully, false otherwise.
Precondition
descriptor->ReadFileDescriptor() is valid.

Implements ola::io::PollerInterface.

◆ RemoveReadDescriptor() [2/2]

bool ola::io::KQueuePoller::RemoveReadDescriptor ( class ConnectedDescriptor descriptor)
virtual

Unregister a ConnectedDescriptor for read events.

Parameters
descriptorthe ConnectedDescriptor to unregister.
Returns
true if unregistered successfully, false otherwise.
Precondition
descriptor->ReadFileDescriptor() is valid.

Implements ola::io::PollerInterface.

◆ RemoveWriteDescriptor()

bool ola::io::KQueuePoller::RemoveWriteDescriptor ( class WriteFileDescriptor descriptor)
virtual

Unregister a WriteFileDescriptor for write events.

Parameters
descriptorthe WriteFileDescriptor to unregister.
Returns
true if unregistered successfully, false otherwise.
Precondition
descriptor->WriteFileDescriptor() is valid.

Implements ola::io::PollerInterface.


The documentation for this class was generated from the following files: