Class ResourceEvent

Class Documentation

class ResourceEvent

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

Public Functions

ResourceEvent()
~ResourceEvent()
void init_thread(const fastdds::rtps::ThreadSettings &thread_cfg = {}, const char *name_fmt = "event %u", uint32_t thread_id = 0)

Method to initialize the internal thread.

Parameters:
  • thread_cfg[in] Settings to apply to the created thread.

  • name_fmt[in] A null-terminated string to be used as the format argument of a snprintf like function, taking thread_id as additional argument, and used to give a name to the created thread.

  • thread_id[in] Single variadic argument passed to the formatting function.

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.