Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hlts2/gfreequeue
Simple lock-free queue written in golang
https://github.com/hlts2/gfreequeue
algorithm cas fast faster golang goroutine-safe hlts2 lock-free queue queue-algorithm
Last synced: about 1 month ago
JSON representation
Simple lock-free queue written in golang
- Host: GitHub
- URL: https://github.com/hlts2/gfreequeue
- Owner: hlts2
- License: mit
- Created: 2018-07-20T02:11:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-23T08:03:06.000Z (about 6 years ago)
- Last Synced: 2024-04-18T17:12:10.711Z (7 months ago)
- Topics: algorithm, cas, fast, faster, golang, goroutine-safe, hlts2, lock-free, queue, queue-algorithm
- Language: Go
- Homepage:
- Size: 143 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gfreequeue
gfreequeue is simple lock-free queue written in golang.
this queue is goroutine-safe.## Requirement
Go (>= 1.8)## Installation
```shell
go get github.com/hlts2/gfreequeue
```
## Example### Basic Example
Enqueu is `Enqueu(value interface{})`, so you can enqueu any type of object
```go
q := New()
q.Enqueue(1)
q.Enqueue(2)
q.Enqueue(3)q.Dequeue() // 1
q.Dequeue() // 2
q.Dequeue() // 3```
### Iterator Support
```go
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](https://github.com/hlts2/gfreequeue) vs [lfreequeue](https://github.com/scryner/lfreequeue) vs [lane](https://github.com/oleiade/lane/tree/v1.0.0)
![Bench](https://github.com/hlts2/gfreequeue/blob/master/images/benchmark.png)
## Author
[hlts2](https://github.com/hlts2)## LICENSE
gfreequeue released under MIT license, refer [LICENSE](https://github.com/hlts2/gfreequeue/blob/master/LICENSE) file.