I've been trying to use already written Wait-free queue by Alex Kogan and Erez Petrank taken from here, but faced the problem. I can't understand that exactly thread ID need to be used in que()
and deque()
methods on page 5 and 7:
void enq(int value) {
long phase = maxPhase() + 1; // cf. Figure 3b
state.set(TID, new
OpDesc(phase, true, true, new Node(value, TID)));
help(phase);
help finish enq();
}
And
int deq() throws EmptyException {
long phase = maxPhase() + 1; // cf. Figure 5a
state.set(TID, new OpDesc(phase, true, false, null));
help(phase);
help finish deq();
Node node = state.get(TID).node;
if (node == null) {
throw new EmptyException();
}
return node.next.get().value;
}
What thread id should used?