https://github.com/austingebauer/c-pthread-pool
C thread pool implementation using POSIX threads (pthreads)
https://github.com/austingebauer/c-pthread-pool
Last synced: 10 months ago
JSON representation
C thread pool implementation using POSIX threads (pthreads)
- Host: GitHub
- URL: https://github.com/austingebauer/c-pthread-pool
- Owner: austingebauer
- License: mit
- Created: 2021-10-22T22:18:29.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-05T06:31:13.000Z (almost 4 years ago)
- Last Synced: 2025-02-08T20:23:58.258Z (12 months ago)
- Language: C
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# c-pthread-pool
C thread pool implementation using POSIX threads (pthreads).
## Usage
```c
#include "threadpool.h"
struct worker_arg {
char* filepath;
int writefd;
};
// Create the thread pool with 8 threads
threadpool_t* tpool = create_thread_pool(8);
// Enqueue work for the thread pool
struct worker_arg warg;
warg.filepath = buffer;
warg.writefd = writefd;
enqueue_thread_pool(tpool, file_worker, &warg);
void* file_worker(void* arg) {
// Parse the worker_arg
struct worker_arg* warg = (struct worker_arg*) arg;
}
```