Skip to content

Commit

Permalink
2
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyiZzz committed Oct 27, 2023
1 parent 49052e2 commit 7fe08a2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions be/src/runtime/thread_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,15 @@ static ThreadContext* thread_context() {
DCHECK(pthread_context_ptr_init);
DCHECK(thread_context_ptr != nullptr);
return thread_context_ptr;
} else {
// in bthread
DCHECK(bthread_context != nullptr);
return bthread_context;
}
// in bthread
if (!bthread_equal(bthread_self(), bthread_id)) {
// bthread switching pthread may be very frequent, remember not to use lock or other time-consuming operations.
bthread_id = bthread_self();
bthread_context = static_cast<ThreadContext*>(bthread_getspecific(btls_key));
}
DCHECK(bthread_context != nullptr);
return bthread_context;
}

class ScopeMemCount {
Expand Down

0 comments on commit 7fe08a2

Please sign in to comment.