C++ Concurrency Sandbox
Loading...
Searching...
No Matches
PriorityTask Struct Reference

A wrapper for a callable task associated with a priority level. More...

Collaboration diagram for PriorityTask:

Public Member Functions

bool operator< (const PriorityTask &other) const
 Comparator for the priority queue.
 

Public Attributes

int priority
 Priority level (higher values indicate higher importance).
 
std::function< void()> func
 The actual task/function to be executed.
 

Detailed Description

A wrapper for a callable task associated with a priority level.

Definition at line 23 of file Priority.cpp.

Member Function Documentation

◆ operator<()

bool PriorityTask::operator< ( const PriorityTask other) const
inline

Comparator for the priority queue.

  • Allows std::priority_queue to order tasks such that the one with the highest priority number is at the top.
    Parameters
    otherThe other task to compare against.
    Returns
    true if this task has lower priority than the other.

Definition at line 34 of file Priority.cpp.

34 {
35 return priority < other.priority;
36 }
int priority
Priority level (higher values indicate higher importance).
Definition Priority.cpp:24

References priority.

Member Data Documentation

◆ func

std::function<void()> PriorityTask::func

The actual task/function to be executed.

Definition at line 25 of file Priority.cpp.

◆ priority

int PriorityTask::priority

Priority level (higher values indicate higher importance).

Definition at line 24 of file Priority.cpp.

Referenced by operator<().


The documentation for this struct was generated from the following file: