提交 51ffc3e6 编写于 作者: B Behdad Esfahbod

Fix previous commit to use atomic operations

上级 88395768
......@@ -639,9 +639,16 @@ struct hb_lazy_loader_t
inline void set_stored (Stored *instance_)
{
if (instance)
thiz ()->destroy (instance);
instance = instance_;
/* This *must* be called when there are no other threads accessing.
* However, to make TSan, etc, happy, we using cmpexch. */
retry:
Stored *p = (Stored *) hb_atomic_ptr_get (&this->instance);
if (p)
{
if (unlikely (!hb_atomic_ptr_cmpexch (const_cast<Stored **>(&this->instance), p, instance_)))
goto retry;
thiz ()->destroy (p);
}
}
inline const Returned * get (void) const
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册