From d9af29a69ac69ee2d17df3e6b90e148cfe4b0f61 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 7 Jan 2018 18:07:04 +0100 Subject: [PATCH] Add readme --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..e568fa0 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# Queue + +[![GoDoc](https://godoc.org/github.com/sheerun/queue?status.svg)](https://godoc.org/github.com/sheerun/queue) +[![Release](https://img.shields.io/github/release/sheerun/queue.svg)](https://github.com/sheerun/queue/releases/latest) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.txt) + +An blocking FIFO queue based on auto-growing circular buffer, without goroutines. + +## Usage + +```go +q := New() + +var wg sync.WaitGroup + +wg.Add(2) + +go func() { + for i := 0; i < 10000; i++ { + q.Append(i) + } + wg.Done() +}() + +go func() { + for i := 0; i < 10000; i++ { + if q.Pop() != i { + t.Errorf("Invalid returned index: %d", i) + wg.Done() + return + } + } + wg.Done() +}() + +wg.Wait() +``` + +## License + +MIT