Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
kcenon::thread::jobs Namespace Reference

Classes

class  job_interface
 Interface for executable job objects. More...
 

Typedefs

using job_ptr = std::shared_ptr<job_interface>
 Shared pointer type for job objects.
 
using job_weak_ptr = std::weak_ptr<job_interface>
 Weak pointer type for job objects.
 
using job_function = std::function<void()>
 Function type for simple callback-based jobs.
 

Enumerations

enum class  job_priority : uint8_t { low = 0 , normal = 1 , high = 2 }
 Job priority levels for type-based scheduling. More...
 
enum class  job_state : uint8_t {
  pending , running , completed , cancelled ,
  failed
}
 Job execution states. More...
 

Functions

job_priority make_priority (int priority_value)
 Utility function to create a job priority from integer.
 
std::string to_string (job_priority priority)
 Convert job priority to string representation.
 
std::string to_string (job_state state)
 Convert job state to string representation.
 

Typedef Documentation

◆ job_function

using kcenon::thread::jobs::job_function = std::function<void()>

Function type for simple callback-based jobs.

Definition at line 94 of file job_types.h.

◆ job_ptr

using kcenon::thread::jobs::job_ptr = std::shared_ptr<job_interface>

Shared pointer type for job objects.

Definition at line 84 of file job_types.h.

◆ job_weak_ptr

Weak pointer type for job objects.

Definition at line 89 of file job_types.h.

Enumeration Type Documentation

◆ job_priority

enum class kcenon::thread::jobs::job_priority : uint8_t
strong

Job priority levels for type-based scheduling.

Enumerator
low 

Low priority jobs (background tasks)

normal 

Normal priority jobs (regular tasks)

high 

High priority jobs (urgent tasks)

Definition at line 22 of file job_types.h.

22 : uint8_t {
23 low = 0,
24 normal = 1,
25 high = 2
26 };
@ low
Between low and high watermark.
@ high
Above high_watermark, approaching capacity.
@ normal
Normal priority, default for most jobs.

◆ job_state

enum class kcenon::thread::jobs::job_state : uint8_t
strong

Job execution states.

Enumerator
pending 

Job is waiting to be executed.

running 

Job is currently being executed.

completed 

Job has completed successfully.

cancelled 

Job was cancelled before execution.

failed 

Job execution failed.

Definition at line 31 of file job_types.h.

31 : uint8_t {
32 pending,
33 running,
34 completed,
35 cancelled,
36 failed
37 };
@ failed
Job execution failed.
@ cancelled
Job was cancelled before execution.
@ running
Job is currently being executed.
@ pending
Job is waiting to be executed.
@ completed
Job has completed successfully.

Function Documentation

◆ make_priority()

job_priority kcenon::thread::jobs::make_priority ( int priority_value)
inlinenodiscard

Utility function to create a job priority from integer.

Parameters
priority_valueInteger priority (0=low, 1=normal, 2=high)
Returns
Corresponding job_priority enum value

Definition at line 101 of file job_types.h.

101 {
102 switch (priority_value) {
103 case 0: return job_priority::low;
104 case 1: return job_priority::normal;
105 case 2: return job_priority::high;
106 default: return job_priority::normal;
107 }
108 }

References high, low, and normal.

◆ to_string() [1/2]

std::string kcenon::thread::jobs::to_string ( job_priority priority)
inlinenodiscard

Convert job priority to string representation.

Parameters
priorityJob priority to convert
Returns
String representation of the priority

Definition at line 115 of file job_types.h.

115 {
116 switch (priority) {
117 case job_priority::low: return "low";
118 case job_priority::normal: return "normal";
119 case job_priority::high: return "high";
120 default: return "unknown";
121 }
122 }

References high, low, normal, and kcenon::thread::priority.

◆ to_string() [2/2]

std::string kcenon::thread::jobs::to_string ( job_state state)
inlinenodiscard

Convert job state to string representation.

Parameters
stateJob state to convert
Returns
String representation of the state

Definition at line 129 of file job_types.h.

129 {
130 switch (state) {
131 case job_state::pending: return "pending";
132 case job_state::running: return "running";
133 case job_state::completed: return "completed";
134 case job_state::cancelled: return "cancelled";
135 case job_state::failed: return "failed";
136 default: return "unknown";
137 }
138 }

References cancelled, completed, failed, pending, and running.