()
| 54 | } |
| 55 | |
| 56 | func (s *stack) Pop() interface{} { |
| 57 | headAddr := (*unsafe.Pointer)(unsafe.Pointer(&s.head)) |
| 58 | for { |
| 59 | head := (*node)(atomic.LoadPointer(headAddr)) |
| 60 | n := head.next() |
| 61 | if n == nil { |
| 62 | return nil |
| 63 | } |
| 64 | if casAddr(headAddr, unsafe.Pointer(head), unsafe.Pointer(n)) { |
| 65 | atomic.AddUint64(&s.count, ^uint64(0)) |
| 66 | return *(*interface{})(head.value()) |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | func (s *stack) Peek() interface{} { |
| 72 | return *(*interface{})(s.head.value()) |