8#ifndef META_OCEAN_TRACKING_SLAM_BACKGROUND_TASK_H
9#define META_OCEAN_TRACKING_SLAM_BACKGROUND_TASK_H
13#include <condition_variable>
67 using Task = std::function<void()>;
std::condition_variable taskExecuteCondition_
The condition variable to signal task execution.
Definition BackgroundTask.h:175
BackgroundTask(const BackgroundTask &backgroundTask)=delete
Disabled copy constructor.
bool released_
True, if the background task has been released or not yet initialized; False, if active.
Definition BackgroundTask.h:187
WaitResult wait()
Waits until the previous task execution has been processed.
bool execute()
Executes the task in the background.
BackgroundTask(BackgroundTask &&backgroundTask)=delete
Disabled move constructor.
bool taskExecute_
True, if the task should be executed; False, otherwise.
Definition BackgroundTask.h:172
BackgroundTask & operator=(BackgroundTask &&backgroundTask)=delete
Disabled move assignment operator.
Task task_
The background task to execute.
Definition BackgroundTask.h:166
~BackgroundTask()
Destructs the background task object.
std::jthread thread_
The background thread.
Definition BackgroundTask.h:169
void release()
Explicitly releases the background task and stops the background thread.
bool taskProcessed_
True, if the task has been processed; False, otherwise.
Definition BackgroundTask.h:178
void threadRun(std::stop_token stopToken)
The internal thread run function.
bool setTask(Task &&task)
Sets the task to be executed in the background.
BackgroundTask()=default
Creates a new background task object without a task.
WaitResult
Definition of individual wait result states.
Definition BackgroundTask.h:55
@ WR_RELEASED
The task was released before completion.
Definition BackgroundTask.h:59
@ WR_INVALID
Invalid wait result.
Definition BackgroundTask.h:57
@ WR_PROCESSED
The task was processed successfully.
Definition BackgroundTask.h:61
std::function< void()> Task
Definition of a task function to be executed in the background.
Definition BackgroundTask.h:67
BackgroundTask & operator=(const BackgroundTask &backgroundTask)=delete
Disabled copy assignment operator.
BackgroundTask(Task &&task)
Creates a new background task object with a given task.
std::mutex mutex_
The mutex protecting the internal state.
Definition BackgroundTask.h:184
std::condition_variable taskProcessedCondition_
The condition variable to signal task completion.
Definition BackgroundTask.h:181
Namespace of the SLAM Tracking library.
Definition BackgroundTask.h:24
Namespace of the Tracker library.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15