#include <gtopt/work_pool.hpp>
template<typename T T = void, typename Key = int64_ t, typename KeyCompare KeyCompare = std::less<Key>>
Task class
Generic task wrapper with type-erased key type.
| Template parameters | |
|---|---|
| T | Result type of the task callable (default void). |
| Key | The priority-key type (must match the pool's key type). |
| KeyCompare | Comparator for the secondary sort. The default std::less<Key> gives "smaller key = higher priority". Use std::greater<Key> for "larger key = higher
priority" (the old pre-refactor behavior for int64_t). |
Public types
- using key_compare = KeyCompare
- using key_type = Key
- using result_type = T
Constructors, destructors, conversion operators
Public functions
- auto age() const -> constexpr auto noexcept
- auto execute() -> void
- auto get_future() -> std::future<T>
- auto operator<(const Task& other) const -> bool noexcept
- auto operator=(const Task&) -> Task& deleted
- auto operator=(Task&&) -> Task& defaulted
- auto requirements() const -> constexpr const BasicTaskRequirements<Key>& noexcept
- auto Task(F&& func, BasicTaskRequirements<Key> req = {}) -> constexpr explicit
Function documentation
bool gtopt:: Task<T, Key, KeyCompare>:: operator<(const Task& other) const noexcept
Returns true when this has lower priority than other (for use in a max-heap: the task at the top — the "greatest" — is dequeued first).
Ordering:
TaskPrioritytier: higher enum value = higher priority.Keycomparison viaKeyCompare:KeyCompare(key1, key2) == true⟹ key1 has higher priority. In a max-heap this meansoperator<returns true whenotherhas higher priority, i.e.KeyCompare(other.key, this.key). With the defaultstd::less<Key>: smaller key → higher priority.- Tie-break: older submission → higher priority.