MCPcopy Create free account
hub / github.com/dustinxie/lockfree / Pop

Method Pop

list/stack.go:56–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54}
55
56func (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
71func (s *stack) Peek() interface{} {
72 return *(*interface{})(s.head.value())

Callers

nothing calls this directly

Calls 3

casAddrFunction · 0.85
nextMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected