Implement TLS and spinlocks, fix bug in Windows threads
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
#define BH_THREAD_DONE 0x0100
|
||||
|
||||
#define BH_MAX_TLS 32
|
||||
|
||||
#if defined(BH_USE_PTHREAD)
|
||||
#include "thread_posix.h"
|
||||
#elif defined(BH_USE_WINTHREAD)
|
||||
@@ -33,6 +35,18 @@ struct bh_thread_pool_s
|
||||
int shutdown;
|
||||
};
|
||||
|
||||
typedef struct bh_tls_info_s
|
||||
{
|
||||
size_t counter;
|
||||
bh_spinlock_t lock;
|
||||
bh_generic_cb_t cleanup[BH_MAX_TLS];
|
||||
} bh_tls_info_t;
|
||||
|
||||
typedef struct bh_tls_s
|
||||
{
|
||||
void *data[BH_MAX_TLS];
|
||||
} bh_tls_t;
|
||||
|
||||
void bh_task_init(bh_task_t *task,
|
||||
void (*func)(void *),
|
||||
void *data,
|
||||
@@ -42,4 +56,14 @@ void bh_task_destroy(bh_task_t *task);
|
||||
|
||||
void bh_thread_pool_worker(void *arg);
|
||||
|
||||
void bh_spinlock_init(bh_spinlock_t *lock);
|
||||
|
||||
void bh_spinlock_destroy(bh_spinlock_t *lock);
|
||||
|
||||
bh_tls_info_t *bh_tls_info(void);
|
||||
|
||||
bh_tls_t *bh_tls_fetch(void);
|
||||
|
||||
void bh_tls_cleanup(void);
|
||||
|
||||
#endif /* BH_INTERNAL_THREAD_H */
|
||||
|
||||
Reference in New Issue
Block a user