Skip to content

AvivDavid23/Thread-Pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thread-Pool

  • A thread pool that can execute up to N tasks at the same time
  • Works only with pthreads

Compile:

gcc *.c *.h -lpthread


API:

Function Description
ThreadPool *tpCreate(int numOfThreads) Create and return a pointer to a new pool, with numOfThreads working threads
void tpDestroy(ThreadPool *threadPool, int shouldWaitForTasks) Destroy the pool and free al resources. if shouldWaitForTasks is not 0, the pool will wait for all the tasks in the queue to be finished. otherwise it will wait for current running tasks to be finish. You won't be able to insert tasks to the queue after this function is called
int tpInsertTask(ThreadPool *threadPool, void (*computeFunc)(void *), void *param) Insert a new task to the thread pool. returns 0 on success

About

Simple thread pool implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published