Class ResourceEvent

Class Documentation

class ResourceEvent

This class centralizes all operations over timed events in the same thread.

Public Functions

ResourceEvent() = default
~ResourceEvent()
void init_thread()

Method to initialize the internal thread.

void stop_thread()
void register_timer(TimedEventImpl *event)

This method informs that a TimedEventImpl has been created.

This method has to be called when creating a TimedEventImpl object.

Parameters

event – TimedEventImpl object that has been created.

void unregister_timer(TimedEventImpl *event)

This method removes a TimedEventImpl object in case it is waiting to be processed by ResourceEvent’s internal thread.

This method has to be called before deleting the TimedEventImpl object. This method cancels any operation of the timer. Then it avoids the situation of the execution thread calling the event handler when it was previously removed.

Parameters

event – TimedEventImpl object that will be deleted and we have to be sure all its operations are cancelled.

void notify(TimedEventImpl *event)

This method notifies to ResourceEvent that the TimedEventImpl object has operations to be scheduled.

These operations can be the cancellation of the timer or starting another async_wait.

Parameters

event – TimedEventImpl object that has operations to be scheduled.

void notify(TimedEventImpl *event, const std::chrono::steady_clock::time_point &timeout)

This method notifies to ResourceEvent that the TimedEventImpl object has operations to be scheduled.

These operations can be the cancellation of the timer or starting another async_wait.

Note

Non-blocking call version of the method.

Parameters
  • event – TimedEventImpl object that has operations to be scheduled.

  • timeout – Maximum blocking time of the method.