TimerSet

Timer set class template.

Each event is added to the timer set along with a data item (see template parameters). The data item is stored internally to the timer set, along with the event delegate, as a convenience to the end-user, who thus does not need to maintain an external pool of the data items associated with each event.

Internally, the timer set works using a single timer event, which is registered to epoll with the time until the soonest scheduled event. When the last scheduled event fires, the timer event is unregistered from epoll.

Constructors

this
this(EpollSelectDispatcher epoll, uint max_events, IAllocator allocator)

Constructor.

Members

Aliases

EventFiredDg
alias EventFiredDg = void delegate(ref EventData data)

Alias for a delegate which is called when a scheduled event fires.

EventSetupDg
alias EventSetupDg = void delegate(ref EventData data)

Alias for a delegate which is called when a scheduled event is registered, allowing the user to setup the required data for the event.

length
alias length = scheduled_events
Undocumented in source.

Functions

clear
void clear()

Unregisters all registered events (thus calls stopTimeout()).

schedule
IEvent schedule(EventSetupDg setup_dg, EventFiredDg fired_dg, ulong schedule_us)

Registers a new event with the scheduler.

scheduled_events
size_t scheduled_events()
stopTimeout
void stopTimeout()

Disables the timer event and unregisters it from epoll.

Interfaces

IEvent
interface IEvent

Interface to a scheduled event.

Variables

events
ObjectPool!(Event) events;

Re-usable pool of scheduled events.

Inherited Members

From TimerEventTimeoutManager

select_client
ISelectClient select_client()
setTimeout
void setTimeout(ulong next_expiration_us)

Enables or changes the timer event time.

stopTimeout
void stopTimeout()

Disables the timer event.

Parameters

EventData

type of data to be stored along with each event

TODO: could probably be adapted to a version which allows simple events without attached data, if we need that.

Meta