Open Lighting Architecture: ola::SelectServerInterface Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Public Member Functions | List of all members
ola::SelectServerInterface Class Referenceabstract

## 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::SelectServerInterface:

## 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 ReadFileDescriptor 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 TimeStamp * | WakeUpTime () const=0
| The time when this SelectServer was woken up.
Public Member Functions inherited from ola::thread::ExecutorInterface
virtual void | Execute (ola::BaseCallback0< void > *callback)=0
| Execute the supplied callback at some point in the future.
virtual void | DrainCallbacks ()=0
| Run all callbacks until there are none left.

## Member Function Documentation

## ◆ AddReadDescriptor() [1/2]

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

Register a ConnectedDescriptor for read-events.

Parameters

  descriptor | the ConnectedDescriptor to add.
  delete_on_close | if 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.

## ◆ AddReadDescriptor() [2/2]

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

Register a ReadFileDescriptor for read-events.

Parameters

  descriptor | the 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.

## ◆ AddWriteDescriptor()

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

Register a WriteFileDescriptor for write-events.

Parameters

  descriptor | the WriteFileDescriptor to add.

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

## ◆ RegisterRepeatingTimeout() [1/2]

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

Execute a callback periodically.

Parameters

  period | the time interval between each execution of the callback.
  callback | the 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.

## ◆ RegisterRepeatingTimeout() [2/2]

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

Execute a callback periodically.

Parameters

  period | the number of milliseconds between each execution of the callback.
  callback | the 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.

## ◆ RegisterSingleTimeout() [1/2]

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

  delay | the time interval to wait before the callback is executed.
  callback | the callback to run. Ownership is transferred.

Returns
  a timeout_id which can be used later to cancel the timeout.

Implements ola::thread::SchedulerInterface.

## ◆ RegisterSingleTimeout() [2/2]

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

  delay | the number of milliseconds before the callback is executed.
  callback | the 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.

## ◆ RemoveReadDescriptor() [1/2]

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

Remove a ConnectedDescriptor for read-events.

Parameters

  descriptor | the 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.

## ◆ RemoveReadDescriptor() [2/2]

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

Remove a ReadFileDescriptor for read-events.

Parameters

  descriptor | the 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.

## ◆ RemoveTimeout()

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

Cancel an existing timeout.

Parameters

  id | the timeout_id returned by a call to RegisterRepeatingTimeout or RegisterSingleTimeout.

Implements ola::thread::SchedulerInterface.

## ◆ RemoveWriteDescriptor()

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

Remove a WriteFileDescriptor for write-events.

Parameters

  descriptor | the 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.

## ◆ WakeUpTime()

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.

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

- include/ola/io/SelectServerInterface.h