template<typename T T = void, typename Key = int64_t, typename KeyCompare KeyCompare = std::less<Key>>
gtopt::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

Task() defaulted
Task(const Task&) deleted
Task(Task&&) defaulted
~Task() defaulted

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
template<typename F F>
auto Task(F&& func, BasicTaskRequirements<Key> req = {}) -> constexpr explicit

Function documentation

template<typename T T, typename Key, typename KeyCompare KeyCompare>
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:

  1. TaskPriority tier: higher enum value = higher priority.
  2. Key comparison via KeyCompare: KeyCompare(key1, key2) == true ⟹ key1 has higher priority. In a max-heap this means operator< returns true when other has higher priority, i.e. KeyCompare(other.key, this.key). With the default std::less<Key>: smaller key → higher priority.
  3. Tie-break: older submission → higher priority.