Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Oct 15th, 2010  |  syntax: C++  |  size: 0.29 KB  |  hits: 70  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. std::shared_ptr<T> pop()
  2. {
  3.    ++threads_in_pop;
  4.    node* old_head=head; #1
  5.    while(old_head && !head.compare_exchange_weak(old_head,old_head->next)); #3
  6.    std::shared_ptr<T> res;
  7.    if(old_head)
  8.    {
  9.       res.swap(old_head->data);
  10.    }
  11.    try_reclaim(old_head); #2
  12.    return res;
  13. }