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

Method Push

list/stack.go:41–54  ·  view source on GitHub ↗
(v interface{})

Source from the content-addressed store, hash-verified

39}
40
41func (s *stack) Push(v interface{}) {
42 n := node{
43 val: unsafe.Pointer(&v),
44 }
45 headAddr := (*unsafe.Pointer)(unsafe.Pointer(&s.head))
46 for {
47 head := atomic.LoadPointer(headAddr)
48 n.nxt = head
49 if casAddr(headAddr, head, unsafe.Pointer(&n)) {
50 atomic.AddUint64(&s.count, 1)
51 return
52 }
53 }
54}
55
56func (s *stack) Pop() interface{} {
57 headAddr := (*unsafe.Pointer)(unsafe.Pointer(&s.head))

Callers

nothing calls this directly

Calls 1

casAddrFunction · 0.85

Tested by

no test coverage detected