https://github.com/isty001/worker
https://github.com/isty001/worker
c pthread thread worker
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/isty001/worker
- Owner: Isty001
- License: mit
- Created: 2017-02-11T21:05:52.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-02-16T12:25:27.000Z (about 5 years ago)
- Last Synced: 2025-01-29T21:54:37.544Z (about 1 year ago)
- Topics: c, pthread, thread, worker
- Language: C
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Small threaded worker s using pthread.
### Example
```c
int execute(char *msg)
{
puts(msg);
if (somethin_went_wrong) {
return -1;
}
return 0;
}
void handle(int err)
{
printf("Something went wrong. Error %d", err);
}
int main(void)
{
Queue *s = queue_new();
uint16_t sleep_ms = 100;
Worker *worker = worker_new(s, (Executor) execute, handle, sleep_ms);
worker_run(worker);
queue_add(s, "Hello");
worker_kill(worker); //or worker_free(worker);
return 0;
}
```