Documentation ¶
Overview ¶
Package lockfree offers lock-free utilities
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFloat64 ¶
AddFloat64 add delta to given address atomically
Types ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue implements lock-free FIFO freelist based queue. ref: https://dl.acm.org/citation.cfm?doid=248052.248106
Example ¶
package main import ( "fmt" "github.com/changkun/lockfree" ) func main() { q := lockfree.NewQueue() q.Enqueue("1st item") q.Enqueue("2nd item") q.Enqueue("3rd item") fmt.Println(q.Dequeue()) fmt.Println(q.Dequeue()) fmt.Println(q.Dequeue()) }
Output: 1st item 2nd item 3rd item
func (*Queue) Dequeue ¶
func (q *Queue) Dequeue() interface{}
Dequeue removes and returns the value at the head of the queue. It returns nil if the queue is empty.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack implements lock-free freelist based stack.
Example ¶
package main import ( "fmt" "github.com/changkun/lockfree" ) func main() { s := lockfree.NewStack() s.Push(1) s.Push(2) s.Push(3) fmt.Println(s.Pop()) fmt.Println(s.Pop()) fmt.Println(s.Pop()) }
Output: 3 2 1
Click to show internal directories.
Click to hide internal directories.