Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/bthread/bthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pthread_mutex_t g_task_control_mutex = PTHREAD_MUTEX_INITIALIZER;
TaskControl* g_task_control = NULL;

extern BAIDU_THREAD_LOCAL TaskGroup* tls_task_group;
EXTERN_BAIDU_VOLATILE_THREAD_LOCAL(TaskGroup*, tls_task_group);
extern void (*g_worker_startfn)();
extern void (*g_tagged_worker_startfn)(bthread_tag_t);
extern void* (*g_create_span_func)();
Expand Down Expand Up @@ -521,15 +522,15 @@ int bthread_timer_del(bthread_timer_t id) {
}

int bthread_usleep(uint64_t microseconds) {
bthread::TaskGroup* g = bthread::tls_task_group;
bthread::TaskGroup* g = bthread::BAIDU_GET_VOLATILE_THREAD_LOCAL(tls_task_group);
if (NULL != g && !g->is_current_pthread_task()) {
return bthread::TaskGroup::usleep(&g, microseconds);
}
return ::usleep(microseconds);
}

int bthread_yield(void) {
bthread::TaskGroup* g = bthread::tls_task_group;
bthread::TaskGroup* g = bthread::BAIDU_GET_VOLATILE_THREAD_LOCAL(tls_task_group);
if (NULL != g && !g->is_current_pthread_task()) {
bthread::TaskGroup::yield(&g);
return 0;
Expand Down