Project Alice
Loading...
Searching...
No Matches
pool.h File Reference
#include "zstd_deps.h"
#include "../zstd.h"
Include dependency graph for pool.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ZSTD_STATIC_LINKING_ONLY   /* ZSTD_customMem */
 

Typedefs

typedef struct POOL_ctx_s POOL_ctx
 
typedef void(* POOL_function) (void *)
 

Functions

POOL_ctxPOOL_create (size_t numThreads, size_t queueSize)
 
POOL_ctxPOOL_create_advanced (size_t numThreads, size_t queueSize, ZSTD_customMem customMem)
 
void POOL_free (POOL_ctx *ctx)
 
void POOL_joinJobs (POOL_ctx *ctx)
 
int POOL_resize (POOL_ctx *ctx, size_t numThreads)
 
size_t POOL_sizeof (const POOL_ctx *ctx)
 
void POOL_add (POOL_ctx *ctx, POOL_function function, void *opaque)
 
int POOL_tryAdd (POOL_ctx *ctx, POOL_function function, void *opaque)
 

Macro Definition Documentation

◆ ZSTD_STATIC_LINKING_ONLY

#define ZSTD_STATIC_LINKING_ONLY   /* ZSTD_customMem */

Definition at line 20 of file pool.h.

Typedef Documentation

◆ POOL_ctx

typedef struct POOL_ctx_s POOL_ctx

Definition at line 23 of file pool.h.

◆ POOL_function

typedef void(* POOL_function) (void *)

POOL_function : The function type that can be added to a thread pool.

Definition at line 67 of file pool.h.

Function Documentation

◆ POOL_add()

void POOL_add ( POOL_ctx ctx,
POOL_function  function,
void *  opaque 
)

POOL_add() : Add the job function(opaque) to the thread pool. ctx must be valid. Possibly blocks until there is room in the queue. Note : The function may be executed asynchronously, therefore, opaque must live until function has been completed.

Definition at line 354 of file pool.c.

Here is the caller graph for this function:

◆ POOL_create()

POOL_ctx * POOL_create ( size_t  numThreads,
size_t  queueSize 
)

POOL_create() : Create a thread pool with at most numThreads threads. numThreads must be at least 1. The maximum number of queued jobs before blocking is queueSize.

Returns
: POOL_ctx pointer on success, else NULL.

Definition at line 326 of file pool.c.

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

◆ POOL_create_advanced()

POOL_ctx * POOL_create_advanced ( size_t  numThreads,
size_t  queueSize,
ZSTD_customMem  customMem 
)

Definition at line 331 of file pool.c.

Here is the caller graph for this function:

◆ POOL_free()

void POOL_free ( POOL_ctx ctx)

POOL_free() : Free a thread pool returned by POOL_create().

Definition at line 339 of file pool.c.

Here is the caller graph for this function:

◆ POOL_joinJobs()

void POOL_joinJobs ( POOL_ctx ctx)

POOL_joinJobs() : Waits for all queued jobs to finish executing.

Definition at line 344 of file pool.c.

◆ POOL_resize()

int POOL_resize ( POOL_ctx ctx,
size_t  numThreads 
)

POOL_resize() : Expands or shrinks pool's number of threads. This is more efficient than releasing + creating a new context, since it tries to preserve and reuse existing threads. numThreads must be at least 1.

Returns
: 0 when resize was successful, !0 (typically 1) if there is an error. note : only numThreads can be resized, queueSize remains unchanged.

Definition at line 349 of file pool.c.

◆ POOL_sizeof()

size_t POOL_sizeof ( const POOL_ctx ctx)

POOL_sizeof() :

Returns
threadpool memory usage note : compatible with NULL (returns 0 in this case)

Definition at line 365 of file pool.c.

Here is the caller graph for this function:

◆ POOL_tryAdd()

int POOL_tryAdd ( POOL_ctx ctx,
POOL_function  function,
void *  opaque 
)

POOL_tryAdd() : Add the job function(opaque) to thread pool if a queue slot is available. Returns immediately even if not (does not block).

Returns
: 1 if successful, 0 if not.

Definition at line 359 of file pool.c.