fsautoproc
Basic file transformation automation management utility
Loading...
Searching...
No Matches
tp.h File Reference

Thread pool API for executing work requests. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

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...
 

Macros

#define TPOPT_LOGFILES   1
 Option bit flag for logging all stdout/stderr output to files.
 

Functions

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().
 

Detailed Description

Thread pool API for executing work requests.

Macro Definition Documentation

◆ TPOPT_LOGFILES

#define TPOPT_LOGFILES   1

Option bit flag for logging all stdout/stderr output to files.

Function Documentation

◆ 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().

Here is the caller graph for this function:

◆ tpinit()

int tpinit ( int size,
int flags )

Initializes a global worker thread pool of the given size.

Parameters
sizeThe number of threads to create, must be greater than 0.
flagsThe flags to use when creating the thread pool.
Returns
0 on success, -1 on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
reqThe work request to allocate.
Returns
0 on success, -1 on failure.
Here is the caller graph for this function:

◆ tpshutdown()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tpwait()

void tpwait ( void )

Waits for all threads in the global pool to finish executing their work requests.

Here is the caller graph for this function: