News for hackers. Stuff that matters.
Re:Lock-free Data Structures Part 1 – Introduction by iano on Tuesday May 06, 2014 @01:01AM (#7702917)
Can someone explain to me how the first queue example's (using singly link lists) dequeue method gives the expected result? Isn't head->m_pNext always NULL, so the new head will always be NULL and tail will be set to NULL losing the rest of the queue?

Seems like you should need to traverse the list to dequeue.

Where did I go wrong?

Re:Lock-free Data Structures Part 1 – Introduction by chacham15 on Tuesday May 06, 2014 @01:11AM (#7702945)
You're right. Enqueue is wrong, it should be:

    if ( !m_pHead )
        m_pHead = p ;
    else
        m_pTail->next = p;
    m_pTail = p;
For some reason, the author is inserting the node in front of the tail leading to the error.
Re:Lock-free Data Structures Part 1 – Introduction by cjensen on Tuesday May 06, 2014 @11:28AM (#7705043)
The complex version doesn't even alter m_pHead in enqueue().