valinurovam / safequeue

SafeQueue is low-level, in-memory, thread-safe, simple and fast FIFO queue in pure Go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SafeQueue Build Status Coverage Status Go Report Card GoDoc

SafeQueue is low-level, in-memory, thread-safe, simple and fast FIFO queue in pure Go.

Getting Started

Installing

$ go get -u github.com/valinurovam/safequeue

API

  • Push(item interface{})
  • PushHead(item interface{})
  • Pop() (item interface{})
  • Length() uint64
  • Purge()

Usage

Populate queue

queue := safequeue.NewSafeQueue(SIZE)
queueLength := SIZE * 8
for item := 0; item < queueLength; item++ {
    queue.Push(item)
}

Fetch items

item := queue.Pop()

Benchmarks

goos: darwin
goarch: amd64
pkg: github.com/valinurovam/safequeue
BenchmarkSafeQueue_Push-8       20000000               119 ns/op
BenchmarkSafeQueue_Pop-8        50000000               25.5 ns/op

License

SafeQueue source code is available under the MIT License.

About

SafeQueue is low-level, in-memory, thread-safe, simple and fast FIFO queue in pure Go.

License:MIT License


Languages

Language:Go 100.0%