https://github.com/jonhoo/pthread_pool
A simple implementation of thread pooling for C/C++ using POSIX threads
https://github.com/jonhoo/pthread_pool
multi-core multithreading posix-threads pthreads thread-pool
Last synced: 11 months ago
JSON representation
A simple implementation of thread pooling for C/C++ using POSIX threads
- Host: GitHub
- URL: https://github.com/jonhoo/pthread_pool
- Owner: jonhoo
- License: mit
- Created: 2014-02-06T14:56:05.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2020-10-01T01:28:44.000Z (over 5 years ago)
- Last Synced: 2025-03-15T14:55:58.586Z (12 months ago)
- Topics: multi-core, multithreading, posix-threads, pthreads, thread-pool
- Language: C
- Size: 176 KB
- Stars: 80
- Watchers: 5
- Forks: 27
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
pthread_pool
============
A simple implementation of thread pooling for C/C++ using POSIX threads.
Each pool has a designated worker function, and expects to be given a number of
work items. Any thread in the pool can take a work item, and will pass the work
item to the pool's worker function. The work items are `void *`, and are passed
to the worker function exactly as they are given to `pool_enqueue`. The return
values of the worker functions are ignored.
Four functions of interest are provided:
- `pool_start` will start a new pool. The worker function and number of
threads in the pool need to be given as arguments.
- `pool_enqueue` will add a new work item to the pool. The work item data
pointer should be passed, as well as a flag specifying whether the work item
should be free'd after the work item has been processed (or if the pool is
terminated).
- `pool_wait` will block until all queued work items have been processed.
- `pool_end` should be called when the pool is no longer needed. This
terminates the threads, deallocates the queue and the pool, as well as any
freeable work items.
Further documentation is given in Doxygen format in `pthread_pool.h`.