src/hotspot/share/utilities/lockFreeStack.hpp
changeset 59252 623722a6aeb9
parent 59251 4cbfa5077d68
equal deleted inserted replaced
59251:4cbfa5077d68 59252:623722a6aeb9
    63     T* cur = top();
    63     T* cur = top();
    64     T* old;
    64     T* old;
    65     do {
    65     do {
    66       old = cur;
    66       old = cur;
    67       set_next(*last, cur);
    67       set_next(*last, cur);
    68       cur = Atomic::cmpxchg(first, &_top, cur);
    68       cur = Atomic::cmpxchg(&_top, cur, first);
    69     } while (old != cur);
    69     } while (old != cur);
    70   }
    70   }
    71 
    71 
    72   // Noncopyable.
    72   // Noncopyable.
    73   LockFreeStack(const LockFreeStack&);
    73   LockFreeStack(const LockFreeStack&);
    89       T* new_top = NULL;
    89       T* new_top = NULL;
    90       if (result != NULL) {
    90       if (result != NULL) {
    91         new_top = next(*result);
    91         new_top = next(*result);
    92       }
    92       }
    93       // CAS even on empty pop, for consistent membar bahavior.
    93       // CAS even on empty pop, for consistent membar bahavior.
    94       result = Atomic::cmpxchg(new_top, &_top, result);
    94       result = Atomic::cmpxchg(&_top, result, new_top);
    95     } while (result != old);
    95     } while (result != old);
    96     if (result != NULL) {
    96     if (result != NULL) {
    97       set_next(*result, NULL);
    97       set_next(*result, NULL);
    98     }
    98     }
    99     return result;
    99     return result;