I am trying to create a package of non-blocking queues for a parallel application using the algorithm of Magad M. Michael and Michael L. Scott, as described here .
This requires the use of atomic CompareAndSwap, offered by the package "sync/atomic" .
However, I'm not sure if the Go equivalent is equivalent to the following pseudo-code:
E9: if CAS(&tail.ptr->next, next, <node, next.count+1>)
where tail and next is of type:
type pointer_t struct { ptr *node_t count uint }
and node is of type:
type node_t struct { value interface{} next pointer_t }
If I understood correctly, it seems to me that I need to make CAS with a structure (both a pointer and a uint ). Is this possible with an atomic package?
Thanks for the help!
source share