diff options
| author | Mistivia <i@mistivia.com> | 2025-09-13 20:53:56 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-09-13 20:53:56 +0800 |
| commit | a4daf467f871b0e77f07f1071b47b960da7bfba9 (patch) | |
| tree | 43b8847b395a90f5aadb57593c0d84e2c13cca7c /task_queue.h | |
| parent | f3eeea1d7092f3ca98836035bf75b941d14c2067 (diff) | |
add s3 client
Diffstat (limited to 'task_queue.h')
| -rw-r--r-- | task_queue.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/task_queue.h b/task_queue.h new file mode 100644 index 0000000..2843fb9 --- /dev/null +++ b/task_queue.h @@ -0,0 +1,28 @@ +#ifndef TASK_QUEUE_H_ +#define TASK_QUEUE_H_ + +#include <pthread.h> + +typedef void (*TaskFn)(void *arg); + +typedef struct { + TaskFn *tasks; + void **args; + int capacity; + int front; + int end; + int size; + pthread_mutex_t lock; + pthread_cond_t not_full; + pthread_cond_t not_empty; +} TaskQueue; + +void TaskQueue_init(TaskQueue *self, int capacity); + +void TaskQueue_destroy(TaskQueue *self); + +void TaskQueue_push(TaskQueue *self, TaskFn task, void *arg); + +void TaskQueue_pop(TaskQueue *self, TaskFn *task, void **arg); + +#endif |
