3 // Make them C-callable interfaces
5 /** @DeclareState: IntList *q;
6 @Commutativity: enq <-> deq (true)
7 @Commutativity: deq <-> deq (M1->C_RET!=-1||M2->C_RET!=-1) */
9 void Queue::enq(int val) {
10 Node *n = new Node(val);
12 Node *t = tail.load(acquire);
13 Node *next = t->next.load(relaxed);
15 if(t->next.CAS(next, n, relaxed)) {
16 /** @OPDefine: true */
17 tail.store(n, release);
24 Node *h = head.load(acquire);
25 Node *t = tail.load(acquire);
26 Node *next = h->next.load(relaxed);
27 /** @OPClearDefine: true */
29 if(head.CAS(h, next, release))
34 /** @Transition: STATE(q)->push_back(val); */
35 void enq(Queue *q, int val) {
40 S_RET = STATE(q)->empty() ? -1 : STATE(q)->front();
42 STATE(q)->pop_front();
44 return C_RET == -1 ? true : C_RET == S_RET;
45 @JustifyingPostcondition: if (C_RET == -1)
46 return S_RET == -1; */