67 int priority() const noexcept {
return _priority; }
74 virtual void run() = 0;
83 template<DerivedFromTask T>
84 T &
as() {
return static_cast<T &
>(*this); }
93 template<DerivedFromTask T>
94 T
const &
as()
const {
return static_cast<T
const &
>(*this); }
Convenience macros to explicitly control copy and move semantics.
Polymorphic unit of work executed by the runtime (typically by ThreadPool).
Definition Task.hpp:48
virtual ~Task()=default
Polymorphic base requires a virtual destructor.
int priority() const noexcept
Task scheduling priority.
Definition Task.hpp:67
T & as()
Unchecked downcast to a concrete task type.
Definition Task.hpp:84
T const & as() const
Unchecked downcast to a concrete task type (const overload).
Definition Task.hpp:94
DISABLE_COPY_AND_MOVE(Task)
Tasks are neither copyable nor movable.
Task(int priority=0)
Construct a task with a given scheduling priority.
Definition Task.hpp:55
virtual void run()=0
Execute the task.
Convenience concept for constraining templates to Task-derived types.
Definition Task.hpp:24
std::unique_ptr< Task > TaskPtr
Unique ownership pointer for tasks.
Definition Task.hpp:102