Implement TLS and spinlocks, fix bug in Windows threads

This commit is contained in:
2024-06-10 22:24:57 +03:00
parent 8939076f94
commit ada9d3ada5
10 changed files with 359 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ typedef struct bh_semaphore_s bh_semaphore_t;
typedef struct bh_cond_s bh_cond_t;
typedef struct bh_task_s bh_task_t;
typedef struct bh_thread_pool_s bh_thread_pool_t;
typedef struct bh_spinlock_s bh_spinlock_t;
#if defined(BH_USE_PTHREAD)
bh_thread_t *bh_thread_new(bh_task_t *task);
@@ -108,4 +109,20 @@ int bh_thread_pool_wait(bh_thread_pool_t *pool);
void bh_thread_pool_free(bh_thread_pool_t *pool);
bh_spinlock_t *bh_spinlock_new(void);
void bh_spinlock_free(bh_spinlock_t *lock);
int bh_spinlock_lock(bh_spinlock_t *lock);
int bh_spinlock_unlock(bh_spinlock_t *lock);
int bh_spinlock_try_lock(bh_spinlock_t *lock);
int bh_tls_alloc(bh_generic_cb_t cleanup);
void *bh_tls_get(int slot);
void bh_tls_set(int slot, void* data);
#endif /* BH_THREAD_H */