fix: explicit set Worker::self_ to thread local

This commit is contained in:
obdev
2023-03-24 10:11:22 +00:00
committed by ob-robot
parent a8778f6a45
commit 51224417e1
7 changed files with 12 additions and 12 deletions

View File

@ -116,6 +116,7 @@ public:
static void set_compatibility_mode(CompatMode mode);
static CompatMode get_compatibility_mode();
static Worker& self();
static void set_worker_to_thread_local(Worker *worker);
public:
static __thread Worker *self_;
@ -154,6 +155,12 @@ private:
extern void *alloc_worker();
extern void common_yield();
inline void Worker::set_worker_to_thread_local(Worker *worker)
{
self_ = worker;
}
inline Worker &Worker::self()
{
// wbuf won't been NULL.