SafeQueue is low-level, in-memory, thread-safe, simple and fast FIFO queue in pure Go.
$ go get -u github.com/valinurovam/safequeue
- Push(item interface{})
- PushHead(item interface{})
- Pop() (item interface{})
- Length() uint64
- Purge()
Populate queue
queue := safequeue.NewSafeQueue(SIZE)
queueLength := SIZE * 8
for item := 0; item < queueLength; item++ {
queue.Push(item)
}
Fetch items
item := queue.Pop()
goos: darwin
goarch: amd64
pkg: github.com/valinurovam/safequeue
BenchmarkSafeQueue_Push-8 20000000 119 ns/op
BenchmarkSafeQueue_Pop-8 50000000 25.5 ns/op
SafeQueue source code is available under the MIT License.