Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
threadpool.h File Reference

Go to the source code of this file.

Typedefs

typedef struct TPool_s TPool
 

Functions

TPoolTPool_create (int nbThreads, int queueSize)
 
void TPool_free (TPool *ctx)
 
void TPool_submitJob (TPool *ctx, void(*job_function)(void *), void *arg)
 
void TPool_jobsCompleted (TPool *ctx)
 

Typedef Documentation

◆ TPool

typedef struct TPool_s TPool

Function Documentation

◆ TPool_create()

TPool * TPool_create ( int nbThreads,
int queueSize )

TPool_create() : Create a thread pool with at most @nbThreads. @nbThreads must be at least 1. @queueSize is the maximum number of pending jobs before blocking.

Returns
: TPool* pointer on success, else NULL.

◆ TPool_free()

void TPool_free ( TPool * ctx)

TPool_free() : Free a thread pool returned by TPool_create(). Waits for the completion of running jobs before freeing resources.

◆ TPool_jobsCompleted()

void TPool_jobsCompleted ( TPool * ctx)

TPool_jobsCompleted() : Blocks until all queued jobs are completed.

◆ TPool_submitJob()

void TPool_submitJob ( TPool * ctx,
void(* job_function )(void *),
void * arg )

TPool_submitJob() : Add @job_function(arg) to the thread pool. @ctx must be valid. Invocation can block if queue is full. Note: Ensure

  • 's lifetime extends until @job_function completes. Alternatively,
  • 's lifetime must be managed by @job_function.