Open Lighting Architecture  0.9.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
ola::io::SelectServerInterface Class Reference

Detailed Description

The interface for the SelectServer.

The SelectServerInterface is used to register Descriptors for events. It's the core of the event manager system, and should really be called IOManager.

SelectServerInterface implementations are required to be reentrant. Descriptors may be added / removed and timeouts set / canceled from within callbacks executed by the SelectServer.

Inheritance diagram for ola::io::SelectServerInterface:
ola::thread::SchedulingExecutorInterface ola::thread::ExecutorInterface ola::thread::SchedulerInterface ola::io::SelectServer ola::PluginAdaptor

Public Member Functions

virtual bool AddReadDescriptor (class ReadFileDescriptor *descriptor)=0
 Register a ReadFileDescriptor for read-events.
virtual bool AddReadDescriptor (class ConnectedDescriptor *descriptor, bool delete_on_close=false)=0
 Register a ConnectedDescriptor for read-events.
virtual void RemoveReadDescriptor (class ReadFileDescriptor *descriptor)=0
 Remove a RemoveReadDescriptor for read-events.
virtual void RemoveReadDescriptor (class ConnectedDescriptor *descriptor)=0
 Remove a ConnectedDescriptor for read-events.
virtual bool AddWriteDescriptor (class WriteFileDescriptor *descriptor)=0
 Register a WriteFileDescriptor for write-events.
virtual void RemoveWriteDescriptor (class WriteFileDescriptor *descriptor)=0
 Remove a WriteFileDescriptor for write-events.
virtual ola::thread::timeout_id RegisterRepeatingTimeout (unsigned int ms, Callback0< bool > *closure)=0
 Execute a callback periodically.
virtual ola::thread::timeout_id RegisterRepeatingTimeout (const ola::TimeInterval &interval, ola::Callback0< bool > *closure)=0
 Execute a callback periodically.
virtual ola::thread::timeout_id RegisterSingleTimeout (unsigned int ms, SingleUseCallback0< void > *closure)=0
 Execute a callback after a certain time interval.
virtual ola::thread::timeout_id RegisterSingleTimeout (const ola::TimeInterval &interval, SingleUseCallback0< void > *closure)=0
 Execute a callback after a certain time interval.
virtual void RemoveTimeout (ola::thread::timeout_id id)=0
 Cancel an existing timeout.
virtual const TimeStampWakeUpTime () const =0
 The time when this SelectServer was woken up.

Member Function Documentation

virtual bool ola::io::SelectServerInterface::AddReadDescriptor ( class ReadFileDescriptor descriptor)
pure virtual

Register a ReadFileDescriptor for read-events.

Parameters
descriptorthe ReadFileDescriptor to add.
Returns
true if the descriptor was added, false if the descriptor was previously added.

When the descriptor is ready for reading, PerformRead() will be called.

Implemented in ola::io::SelectServer, and ola::PluginAdaptor.

virtual bool ola::io::SelectServerInterface::AddReadDescriptor ( class ConnectedDescriptor descriptor,
bool  delete_on_close = false 
)
pure virtual

Register a ConnectedDescriptor for read-events.

Parameters
descriptorthe ConnectedDescriptor to add.
delete_on_closeif true, ownership of the ConnectedDescriptor is transferred to the SelectServer.
Returns
true if the descriptor was added, false if the descriptor was previously added.

When the descriptor is ready for reading, PerformRead() will be called. Prior to PerformRead(), IsClosed() is called. If this returns true, and delete_on_close was set, the descriptor will be deleted.

Implemented in ola::io::SelectServer, and ola::PluginAdaptor.

virtual bool ola::io::SelectServerInterface::AddWriteDescriptor ( class WriteFileDescriptor descriptor)
pure virtual

Register a WriteFileDescriptor for write-events.

Parameters
descriptorthe WriteFileDescriptor to add.

When the descriptor is writeable, PerformWrite() is called.

Implemented in ola::io::SelectServer, and ola::PluginAdaptor.

virtual ola::thread::timeout_id ola::io::SelectServerInterface::RegisterRepeatingTimeout ( unsigned int  period,
Callback0< bool > *  callback 
)
pure virtual

Execute a callback periodically.

Parameters
periodthe number of milliseconds between each execution of the callback.
callbackthe callback to run. Ownership is transferred.
Returns
a timeout_id which can be used later to cancel the timeout.
Deprecated:
Use the version that takes a TimeInterval instead.

Returning false from the callback will cause it to be cancelled.

Implements ola::thread::SchedulerInterface.

Implemented in ola::io::SelectServer, and ola::PluginAdaptor.

virtual ola::thread::timeout_id ola::io::SelectServerInterface::RegisterRepeatingTimeout ( const ola::TimeInterval period,
ola::Callback0< bool > *  callback 
)
pure virtual

Execute a callback periodically.

Parameters
periodthe time interval between each execution of the callback.
callbackthe callback to run. Ownership is transferred.
Returns
a timeout_id which can be used later to cancel the timeout.

Returning false from the callback will cause it to be cancelled.

Implements ola::thread::SchedulerInterface.

Implemented in ola::io::SelectServer, and ola::PluginAdaptor.

virtual ola::thread::timeout_id ola::io::SelectServerInterface::RegisterSingleTimeout ( unsigned int  delay,
SingleUseCallback0< void > *  callback 
)
pure virtual

Execute a callback after a certain time interval.

Parameters
delaythe number of milliseconds before the callback is executed.
callbackthe callback to run. Ownership is transferred.
Returns
a timeout_id which can be used later to cancel the timeout.
Deprecated:
Use the version that takes a TimeInterval instead.

Implements ola::thread::SchedulerInterface.

Implemented in ola::io::SelectServer, and ola::PluginAdaptor.

virtual ola::thread::timeout_id ola::io::SelectServerInterface::RegisterSingleTimeout ( const ola::TimeInterval delay,
SingleUseCallback0< void > *  callback 
)
pure virtual

Execute a callback after a certain time interval.

Parameters
delaythe time interval to wait before the callback is executed.
callbackthe callback to run. Ownership is transferred.
Returns
a timeout_id which can be used later to cancel the timeout.

Implements ola::thread::SchedulerInterface.

Implemented in ola::io::SelectServer, and ola::PluginAdaptor.

virtual void ola::io::SelectServerInterface::RemoveReadDescriptor ( class ReadFileDescriptor descriptor)
pure virtual

Remove a RemoveReadDescriptor for read-events.

Parameters
descriptorthe descriptor to remove.
Warning
Descriptors must be removed from the SelectServer before they are closed. Not doing so will result in hard to debug failures.

Implemented in ola::io::SelectServer, and ola::PluginAdaptor.

virtual void ola::io::SelectServerInterface::RemoveReadDescriptor ( class ConnectedDescriptor descriptor)
pure virtual

Remove a ConnectedDescriptor for read-events.

Parameters
descriptorthe descriptor to remove.
Warning
Descriptors must be removed from the SelectServer before they are closed. Not doing so will result in hard to debug failures.

Implemented in ola::io::SelectServer, and ola::PluginAdaptor.

virtual void ola::io::SelectServerInterface::RemoveTimeout ( ola::thread::timeout_id  id)
pure virtual

Cancel an existing timeout.

Parameters
idthe timeout_id returned by a call to RegisterRepeatingTimeout or RegisterSingleTimeout.

Implements ola::thread::SchedulerInterface.

Implemented in ola::io::SelectServer, and ola::PluginAdaptor.

virtual void ola::io::SelectServerInterface::RemoveWriteDescriptor ( class WriteFileDescriptor descriptor)
pure virtual

Remove a WriteFileDescriptor for write-events.

Parameters
descriptorthe descriptor to remove.
Warning
Descriptors must be removed from the SelectServer before they are closed. Not doing so will result in hard to debug failures.

Implemented in ola::io::SelectServer, and ola::PluginAdaptor.

virtual const TimeStamp* ola::io::SelectServerInterface::WakeUpTime ( ) const
pure virtual

The time when this SelectServer was woken up.

Returns
The TimeStamp of when the SelectServer was woken up.

If running within the same thread as the SelectServer, this is a efficient way to get the current time.

Implemented in ola::io::SelectServer, and ola::PluginAdaptor.


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