pub fn push(&self, item: T) {
        let node_ptr = Box::into_raw(Box::new(Node {
            item: MaybeUninit::new(item),
            next: AtomicPtr::default(),
        }));

        let mut cur_head_ptr = self.head.load(Acquire);

        loop {
            unsafe {
                (*node_ptr).next.store(cur_head_ptr, Relaxed);
            }
            fence(Acquire);

            let result = self
                .head
                .compare_exchange(cur_head_ptr, node_ptr, Relaxed, Relaxed);

            match result {
                Ok(_) => return,
                Err(current) => cur_head_ptr = current,
            }
        }
    }
/// Add an item to the stack
Add an item to the stack
Add an item to the stack
pub fn push(&self, item: T) {
        let node_ptr = Box::into_raw(Box::new(Node {
            item: MaybeUninit::new(item),
            next: AtomicPtr::default(),
        }));
        let mut cur_head_ptr = self.head.load(Acquire);
        loop {
            unsafe {
                (*node_ptr).next.store(cur_head_ptr, Relaxed);
            }
            fence(Acquire);
            let result = self
                .head
                .compare_exchange(cur_head_ptr, node_ptr, Relaxed, Relaxed);
            match result {
                Ok(_) => return,
                Err(current) => cur_head_ptr = current,
            }
        }
    }
pub fn push ( & self , item : T ) { let node_ptr = Box :: into_raw ( Box :: new ( Node { item : MaybeUninit :: new ( item ) , next : AtomicPtr :: default ( ) , } ) ) ; let mut cur_head_ptr = self . head . load ( Acquire ) ; loop { unsafe { ( * node_ptr ) . next . store ( cur_head_ptr , Relaxed ) ; } fence ( Acquire ) ; let result = self . head . compare_exchange ( cur_head_ptr , node_ptr , Relaxed , Relaxed ) ; match result { Ok ( _ ) => return , Err ( current ) => cur_head_ptr = current , } } }
Add an item to the stack
Add an item to the stack
&self
item
T
&self
item
T