Skip to content

hlts2/gfreequeue

Repository files navigation

gfreequeue

gfreequeue is simple lock-free queue written in golang. this queue is goroutine-safe.

Requirement

Go (>= 1.8)

Installation

go get github.com/hlts2/gfreequeue

Example

Basic Example

Enqueu is Enqueu(value interface{}), so you can enqueu any type of object

q := New()

q.Enqueue(1)
q.Enqueue(2)
q.Enqueue(3)

q.Dequeue() // 1
q.Dequeue() // 2
q.Dequeue() // 3

Iterator Support

q := New()

q.Enqueue(1)
q.Enqueue(2)
q.Enqueue(3)

q.Iterator() // [1, 2, 3]

/*
for _, v := range q.Iterator() {
  fmt.Println(v)
}
*/

Benchmarks

gfreequeue vs lfreequeue vs lane

Bench

Author

hlts2

LICENSE

gfreequeue released under MIT license, refer LICENSE file.