12 #ifndef ROC_CTL_CONTROL_TASK_H_
13 #define ROC_CTL_CONTROL_TASK_H_
20 #include "roc_core/semaphore.h"
27 class ControlTaskQueue;
30 class IControlTaskExecutor;
31 class IControlTaskCompleter;
72 : state_(StateCompleted)
76 , renewed_deadline_(0)
77 , effective_deadline_(0)
78 , effective_version_(0)
113 FlagSucceeded = (1 << 0),
116 FlagPaused = (1 << 2),
119 FlagResumed = (1 << 3),
122 FlagCancelled = (1 << 4),
126 FlagDestroyed = (1 << 5)
130 static void validate_flags(
unsigned task_flags);
135 core::Atomic<uint32_t> state_;
138 core::Atomic<uint32_t> flags_;
141 core::Atomic<uint32_t> renew_guard_;
144 core::Atomic<uint32_t> wait_guard_;
147 core::Seqlock<core::nanoseconds_t> renewed_deadline_;
162 IControlTaskExecutor* executor_;
165 IControlTaskCompleter* completer_;
168 core::Atomic<core::Semaphore*> sem_;
169 core::Optional<core::Semaphore> sem_holder_;
Base class for List element.
Base class for MpscQueue element.
Base class for control tasks.
bool succeeded() const
True if the task succeeded.
ControlTask(ControlTaskResult(E::*task_func)(ControlTask &))
Initialize task.
bool completed() const
True if the task succeeded, failed, or cancelled.
bool cancelled() const
True if the task cancelled.
Control task executor interface.
uint32_t seqlock_version_t
Type for holding seqlock value version. Version is changed each value update. May wrap.
int64_t nanoseconds_t
Nanoseconds.
ControlTaskResult
Control task execution result.
@ ControlTaskPause
Task wants to be paused until is explicitly resumed.
@ ControlTaskContinue
Task wants to be re-executed again as soon as possible.
@ ControlTaskSuccess
Task completed with success.
@ ControlTaskFailure
Task completed with failure.
ControlTaskResult(IControlTaskExecutor::* ControlTaskFunc)(ControlTask &)
Control task implementation function. Holds a pointer to method of a class derived from IControlTaskE...
Optionally constructed object.