xref: /aosp_15_r20/external/mesa3d/src/gallium/frontends/nine/threadpool.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2012 Intel Corporation
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #ifndef _THREADPOOL_H_
7 #define _THREADPOOL_H_
8 
9 #include <pthread.h>
10 
11 struct NineSwapChain9;
12 
13 #define MAXTHREADS 1
14 
15 struct threadpool {
16     pthread_mutex_t m;
17     pthread_cond_t new_work;
18 
19     HANDLE wthread;
20     pthread_t pthread;
21     struct threadpool_task *workqueue;
22     BOOL shutdown;
23 };
24 
25 typedef void (*threadpool_task_func)(void *data);
26 
27 struct threadpool_task {
28     threadpool_task_func work;
29     void *data;
30     struct threadpool_task *next;
31     pthread_cond_t finish;
32     BOOL finished;
33 };
34 
35 struct threadpool *_mesa_threadpool_create(struct NineSwapChain9 *swapchain);
36 void _mesa_threadpool_destroy(struct NineSwapChain9 *swapchain, struct threadpool *pool);
37 struct threadpool_task *_mesa_threadpool_queue_task(struct threadpool *pool,
38                                                     threadpool_task_func func,
39                                                     void *data);
40 void _mesa_threadpool_wait_for_task(struct threadpool *pool,
41                                     struct threadpool_task **task);
42 #endif
43