Thread pool API for executing work requests.
More...
Go to the source code of this file.
|
struct | tpreq_s |
| Pending work request which contains a command set to execute on a thread in the pool, using a file node as the target. More...
|
|
|
#define | TPOPT_LOGFILES 1 |
| Option bit flag for logging all stdout/stderr output to files.
|
|
|
int | tpinit (int size, int flags) |
| Initializes a global worker thread pool of the given size.
|
|
int | tpqueue (const struct tpreq_s *req) |
| Allocates a work request to the first available thread in the global pool. If no threads are available, the request will block until a thread becomes available.
|
|
void | tpwait (void) |
| Waits for all threads in the global pool to finish executing their work requests.
|
|
void | tpshutdown (void) |
| Waits for all threads in the global pool to finish executing their work requests, and then shuts down the pool and exits its threads. This function should be followed by a call to tpfree() .
|
|
void | tpfree (void) |
| Frees all memory allocated by tpinit() . This function should be called at the end of the program. It is safe to call this function even if tpinit() was not called. This function should be called directly after tpshutdown() .
|
|
Thread pool API for executing work requests.
◆ TPOPT_LOGFILES
Option bit flag for logging all stdout/stderr output to files.
◆ tpfree()
Frees all memory allocated by tpinit()
. This function should be called at the end of the program. It is safe to call this function even if tpinit()
was not called. This function should be called directly after tpshutdown()
.
◆ tpinit()
int tpinit |
( |
int | size, |
|
|
int | flags ) |
Initializes a global worker thread pool of the given size.
- Parameters
-
size | The number of threads to create, must be greater than 0. |
flags | The flags to use when creating the thread pool. |
- Returns
- 0 on success, -1 on failure.
◆ tpqueue()
int tpqueue |
( |
const struct tpreq_s * | req | ) |
|
Allocates a work request to the first available thread in the global pool. If no threads are available, the request will block until a thread becomes available.
- Parameters
-
req | The work request to allocate. |
- Returns
- 0 on success, -1 on failure.
◆ tpshutdown()
Waits for all threads in the global pool to finish executing their work requests, and then shuts down the pool and exits its threads. This function should be followed by a call to tpfree()
.
◆ tpwait()
Waits for all threads in the global pool to finish executing their work requests.