diff options
| author | gingerBill <bill@gingerbill.org> | 2022-12-20 12:46:33 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-12-20 12:46:33 +0000 |
| commit | 0edda2bea769303166eaab2965f6cfb8b2bd807c (patch) | |
| tree | 16723d7222d7a86a5fb6704f8e79b35ebaa5a5cd /src/thread_pool.cpp | |
| parent | a13e2f4578eb5557afb8bc6b21930032bedbbb43 (diff) | |
Clarify ThreadPool interface; Move `import_mutex` guarding to just the string set
Diffstat (limited to 'src/thread_pool.cpp')
| -rw-r--r-- | src/thread_pool.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/thread_pool.cpp b/src/thread_pool.cpp index 1b3e74fbe..eca4d37ab 100644 --- a/src/thread_pool.cpp +++ b/src/thread_pool.cpp @@ -1,14 +1,25 @@ // thread_pool.cpp +struct WorkerTask; +struct ThreadPool; + #define WORKER_TASK_PROC(name) isize name(void *data) typedef WORKER_TASK_PROC(WorkerTaskProc); +gb_internal void thread_pool_init(ThreadPool *pool, gbAllocator const &a, isize thread_count, char const *worker_name); +gb_internal void thread_pool_destroy(ThreadPool *pool); +gb_internal bool thread_pool_add_task(ThreadPool *pool, WorkerTaskProc *proc, void *data); +gb_internal void thread_pool_wait(ThreadPool *pool); + + struct WorkerTask { WorkerTask * next; WorkerTaskProc *do_work; void * data; + ThreadPool * pool; }; + struct ThreadPool { gbAllocator allocator; BlockingMutex mutex; @@ -89,6 +100,7 @@ gb_internal bool thread_pool_add_task(ThreadPool *pool, WorkerTaskProc *proc, vo GB_PANIC("Out of memory"); return false; } + task->pool = pool; task->do_work = proc; task->data = data; |