2018-01-27 01:18:10 +00:00
|
|
|
#ifndef LLARP_THREADPOOL_H
|
|
|
|
#define LLARP_THREADPOOL_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-01-29 14:27:24 +00:00
|
|
|
struct llarp_threadpool;
|
2018-01-27 01:18:10 +00:00
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
struct llarp_threadpool *
|
|
|
|
llarp_init_threadpool(int workers, const char *name);
|
|
|
|
void
|
|
|
|
llarp_free_threadpool(struct llarp_threadpool **tp);
|
2018-01-27 01:18:10 +00:00
|
|
|
|
2018-02-01 13:21:00 +00:00
|
|
|
typedef void (*llarp_thread_work_func)(void *);
|
2018-01-31 19:59:26 +00:00
|
|
|
|
2018-01-29 14:27:24 +00:00
|
|
|
/** job to be done in worker thread */
|
2018-05-22 15:54:19 +00:00
|
|
|
struct llarp_thread_job
|
|
|
|
{
|
2018-01-29 14:27:24 +00:00
|
|
|
/** user data to pass to work function */
|
|
|
|
void *user;
|
|
|
|
/** called in threadpool worker thread */
|
2018-01-31 19:59:26 +00:00
|
|
|
llarp_thread_work_func work;
|
2018-01-29 14:27:24 +00:00
|
|
|
};
|
2018-01-27 01:18:10 +00:00
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
void
|
|
|
|
llarp_threadpool_queue_job(struct llarp_threadpool *tp,
|
|
|
|
struct llarp_thread_job j);
|
2018-01-29 14:27:24 +00:00
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
void
|
|
|
|
llarp_threadpool_stop(struct llarp_threadpool *tp);
|
|
|
|
void
|
|
|
|
llarp_threadpool_join(struct llarp_threadpool *tp);
|
2018-04-30 16:14:20 +00:00
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
void
|
|
|
|
llarp_threadpool_wait(struct llarp_threadpool *tp);
|
2018-01-27 01:18:10 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|