我正在使用Hazard指针来实现C语言中的无锁链表。除了非常基本的队列和栈之外,我没有找到任何其他示例代码。 问题是我需要遍历链表,所以我的问题是:一旦分配了危险指针,我是否可以更改其值。 例如:
t←Top
while(true) {
if t=null then
return null
*hp←t
if Top!=t then
continue
...
t←(t→next) //after this instruction pointer t will be still protected?
}