This repository has been archived on 2026-04-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
bhlib-old/include/bh/internal/thread.h

46 lines
819 B
C
Raw Normal View History

#ifndef BH_INTERNAL_THREAD_H
#define BH_INTERNAL_THREAD_H
2024-04-14 22:32:58 +03:00
#include <bh/thread.h>
#include "queue.h"
#define BH_THREAD_DONE 0x0100
2024-04-14 22:32:58 +03:00
#if defined(BH_USE_PTHREAD)
2024-04-14 22:32:58 +03:00
#include "thread_posix.h"
#elif defined(BH_USE_WINTHREAD)
2024-04-14 22:32:58 +03:00
#include "thread_win.h"
#else
#include "thread_null.h"
#endif
struct bh_task_s
{
void (*func)(void *);
void *data;
int flags;
};
struct bh_thread_pool_s
{
bh_thread_t *threads;
bh_queue_t tasks;
bh_mutex_t lock;
bh_cond_t new_task;
bh_cond_t done_task;
size_t size;
size_t active;
int shutdown;
};
void bh_task_init(bh_task_t *task,
void (*func)(void *),
void *data,
int flags);
void bh_task_destroy(bh_task_t *task);
void bh_thread_pool_worker(void *arg);
#endif /* BH_INTERNAL_THREAD_H */