17 #ifndef IOX_UTILS_CONCURRENT_PERIODIC_TASK_HPP
18 #define IOX_UTILS_CONCURRENT_PERIODIC_TASK_HPP
20 #include "iceoryx_utils/cxx/string.hpp"
21 #include "iceoryx_utils/internal/units/duration.hpp"
22 #include "iceoryx_utils/posix_wrapper/semaphore.hpp"
23 #include "iceoryx_utils/posix_wrapper/thread.hpp"
74 template <
typename... Args>
85 template <
typename... Args>
89 Args&&... args) noexcept;
111 void stop() noexcept;
126 std::thread m_taskExecutor;
132 #include "iceoryx_utils/internal/concurrent/periodic_task.inl"
static result_t create(Targs &&... args) noexcept
factory method which guarantees that either a working object is produced or an error value describing...
Definition: creation.inl:41
This class periodically executes a callable specified by the template parameter. This can be a struct...
Definition: periodic_task.hpp:65
bool isActive() const noexcept
This method check if a thread is spawned and running, potentially executing a task.
Definition: periodic_task.inl:71
PeriodicTask(const PeriodicTaskManualStart_t, const posix::ThreadName_t taskName, Args &&... args) noexcept
Creates a periodic task. The specified callable is stored but not executed. To run the task,...
Definition: periodic_task.inl:26
~PeriodicTask() noexcept
Stops and joins the thread spawned by the constructor.
Definition: periodic_task.inl:46
void stop() noexcept
This stops the thread if it's running, otherwise does nothing. When this method returns,...
Definition: periodic_task.inl:61
void start(const units::Duration interval) noexcept
Spawns a thread and immediately executes the callable specified with the constructor....
Definition: periodic_task.inl:52
Posix semaphore C++ Wrapping class.
Definition: semaphore.hpp:84
Definition: duration.hpp:77
static constexpr Duration fromMilliseconds(const T value) noexcept
Constructs a new Duration object from milliseconds.
Definition: duration.inl:88
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:28
This is a helper struct to make the immediate start of the task in the PeriodicTask ctor obvious to t...
Definition: periodic_task.hpp:35
This is a helper struct to make the manual start of the task with the start method obvious to the use...
Definition: periodic_task.hpp:41