首先,无锁队列的实现基于原子操作CAS(_sync_vale_compare_and_swap)
GCC下的CAS实现:
bool __sync_bool_compare_and_swap (type *accum, type *dest, type newval){
if(*accum==*dest){
*dest=newval;
return true;
}
return false;
}
type __sync_val_compare_and_swap (type *ptr, type oldval, type ne