提交 469d0808 编写于 作者: M Megvii Engine Team

fix(asan/thread): fix asan issue

GitOrigin-RevId: 8e2b093fb1f696cc78091c28817fbada1feaa9d8
上级 eb826422
......@@ -18,6 +18,12 @@ using namespace mgb;
#if MGB_THREAD_SAFE
const std::thread::id RecursiveSpinlock::sm_none_owner = std::thread::id();
//! why not use initializer_list for global var, detail:
//! MGE-1738
RecursiveSpinlock::RecursiveSpinlock() {
m_owner = sm_none_owner;
}
void RecursiveSpinlock::lock() {
auto tid = std::this_thread::get_id();
if (m_owner.load(std::memory_order_relaxed) != tid) {
......
......@@ -33,15 +33,15 @@ class Spinlock final: public NonCopyableObj {
};
//! recursive spinlock
class RecursiveSpinlock final: public NonCopyableObj {
class RecursiveSpinlock final : public NonCopyableObj {
static const std::thread::id sm_none_owner;
std::atomic<std::thread::id> m_owner{sm_none_owner};
std::atomic<std::thread::id> m_owner;
size_t m_recur_count = 0;
public:
void lock();
void unlock();
public:
RecursiveSpinlock();
void lock();
void unlock();
};
} // namespace mgb
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册