~christian-rorvik/crunch.concurrency/trunk

« back to all changes in this revision

Viewing changes to source/waiter_list.cpp

  • Committer: Christian Rorvik
  • Date: 2011-11-27 20:49:34 UTC
  • Revision ID: christian.rorvik@gmail.com-20111127204934-e35glretrsbq0qhz
Refactored Atomic CompareAndSwap to take comparand as first argument

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
            {
30
30
                // If waiter is at head, do simple pop
31
31
                std::uint64_t const newHead = SetPointer(head, headPtr->next) + ABA_ADDEND;
32
 
                if (CompareAndSwap(newHead, head))
 
32
                if (CompareAndSwap(head, newHead))
33
33
                    return true;
34
34
            }
35
35
            else
36
36
            {
37
37
                // Lock list from concurrent removal. Scan and remove waiter.
38
 
                if (CompareAndSwap((head | LOCK_BIT) + ABA_ADDEND, head))
 
38
                if (CompareAndSwap(head, (head | LOCK_BIT) + ABA_ADDEND))
39
39
                {
40
40
                    bool removed = RemoveWaiterFromListNotAtHead(headPtr, waiter);
41
41
                    And(~LOCK_BIT, MEMORY_ORDER_RELEASE);