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

Options for submitting jobs to the thread pool. More...

#include <submit_options.h>

Collaboration diagram for kcenon::thread::submit_options:
Collaboration graph

Public Member Functions

 submit_options ()=default
 Default constructor with all defaults.
 
 submit_options (std::string job_name)
 Construct with job name only.
 

Static Public Member Functions

static submit_options named (std::string job_name)
 Create options for a named job.
 
static submit_options all ()
 Create options for wait_all batch operation.
 
static submit_options any ()
 Create options for wait_any batch operation.
 

Public Attributes

std::string name
 Optional name for the job (useful for debugging/tracing).
 
bool wait_all = false
 If true, wait for all tasks and return results directly.
 
bool wait_any = false
 If true, return the first completed result.
 

Detailed Description

Options for submitting jobs to the thread pool.

This struct provides a unified way to configure job submission behavior, replacing the need for multiple submit method variants.

Basic Usage

// Default options (equivalent to submit_async)
auto future = pool->submit([]{ return 42; });
// With job name
auto future = pool->submit([]{ return 42; }, {.name = "compute_task"});

Batch Usage

std::vector<std::function<int()>> tasks = {...};
// Get futures for each task
auto futures = pool->submit(std::move(tasks));
// Wait for all and get results
auto results = pool->submit(std::move(tasks), {.wait_all = true});
// Get first completed result
auto result = pool->submit(std::move(tasks), {.wait_any = true});

Definition at line 51 of file submit_options.h.

Constructor & Destructor Documentation

◆ submit_options() [1/2]

kcenon::thread::submit_options::submit_options ( )
default

Default constructor with all defaults.

◆ submit_options() [2/2]

kcenon::thread::submit_options::submit_options ( std::string job_name)
inlineexplicit

Construct with job name only.

Parameters
job_nameName for the job.

Definition at line 90 of file submit_options.h.

90: name(std::move(job_name)) {}
std::string name
Optional name for the job (useful for debugging/tracing).

Member Function Documentation

◆ all()

static submit_options kcenon::thread::submit_options::all ( )
inlinestatic

Create options for wait_all batch operation.

Returns
submit_options with wait_all = true.

Definition at line 107 of file submit_options.h.

107 {
108 submit_options opts;
109 opts.wait_all = true;
110 return opts;
111 }
submit_options()=default
Default constructor with all defaults.

References wait_all.

◆ any()

static submit_options kcenon::thread::submit_options::any ( )
inlinestatic

Create options for wait_any batch operation.

Returns
submit_options with wait_any = true.

Definition at line 117 of file submit_options.h.

117 {
118 submit_options opts;
119 opts.wait_any = true;
120 return opts;
121 }

References wait_any.

◆ named()

static submit_options kcenon::thread::submit_options::named ( std::string job_name)
inlinestatic

Create options for a named job.

Parameters
job_nameName for the job.
Returns
submit_options with name set.

Definition at line 97 of file submit_options.h.

97 {
98 submit_options opts;
99 opts.name = std::move(job_name);
100 return opts;
101 }

References name.

Member Data Documentation

◆ name

std::string kcenon::thread::submit_options::name

Optional name for the job (useful for debugging/tracing).

When empty, a default name like "async_job" is used.

Definition at line 57 of file submit_options.h.

Referenced by named(), and kcenon::thread::thread_pool::submit().

◆ wait_all

bool kcenon::thread::submit_options::wait_all = false

If true, wait for all tasks and return results directly.

Only applicable for batch submissions. When set:

  • submit() blocks until all tasks complete
  • Returns std::vector<R> instead of std::vector<std::future<R>>
Note
Mutually exclusive with wait_any

Definition at line 68 of file submit_options.h.

Referenced by all().

◆ wait_any

bool kcenon::thread::submit_options::wait_any = false

If true, return the first completed result.

Only applicable for batch submissions. When set:

  • submit() blocks until any task completes
  • Returns R instead of std::vector<std::future<R>>
Note
Mutually exclusive with wait_all

Definition at line 79 of file submit_options.h.

Referenced by any().


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