Skip to content

Commit

Permalink
bump to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
hedzr committed Apr 8, 2022
1 parent 6edae43 commit 8b5ad7c
Showing 1 changed file with 41 additions and 19 deletions.
60 changes: 41 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# go-ringbuf
# go-ringbuf [V2]

![Go](https://github.com/hedzr/go-ringbuf/workflows/Go/badge.svg)
[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/hedzr/go-ringbuf.svg?label=release)](https://github.com/hedzr/go-ringbuf/releases)
Expand All @@ -19,11 +19,14 @@ MPMC (multiple-producers and multiple consumers) enabled.

## History

WIP:
- english documentation not completed yet
- documentation at: https:
### v2.0.0 @20220408 - go 1.18+

### v1.0.0
generic version for MPMC Ring Buffer.

- rewritten with go generics


### v1.0.0 @20220408

Last release for classical version.

Expand All @@ -42,29 +45,45 @@ Next release (v2) will move to go 1.18+ with generic enabled.
## Getting Start

```bash
go get -v github.com/hedzr/go-ringbuf
go get -v github.com/hedzr/go-ringbuf/v2
```

### Import

### Samples

```go
import "github.com/hedzr/go-ringbuf/fast"
```
package main

import (
"fmt"
"github.com/hedzr/go-ringbuf/v2"
"log"
)

func main() {
testIntRB()
testStringRB()
}

### Simple 1
func testStringRB() {
var err error
var rb = ringbuf.New[string](80)
err = rb.Enqueue("abcde")
errChk(err)

```go
import "github.com/hedzr/go-ringbuf/fast"
var item string
item, err = rb.Dequeue()
errChk(err)
fmt.Printf("dequeue ok: %v\n", item)
}

func main() {
func testIntRB() {
var err error
var rb = fast.New(80)
var rb = ringbuf.New[int](80)
err = rb.Enqueue(3)
errChk(err)
var item interface{}

var item int
item, err = rb.Dequeue()
errChk(err)
fmt.Printf("dequeue ok: %v\n", item)
Expand All @@ -81,6 +100,8 @@ func errChk(err error) {

### Using Ring-Buffer as a fixed resource pool

The following codes is for v1, needed for rewriting

```go
func newRes() *Res{...}

Expand Down Expand Up @@ -129,7 +150,8 @@ Welcome

## LICENSE

MIT
Apache 2.0


[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhedzr%2Fgo-ringbuf.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhedzr%2Fgo-ringbuf?ref=badge_large)
<!--
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhedzr%2Fgo-ringbuf.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhedzr%2Fgo-ringbuf?ref=badge_large)
-->

0 comments on commit 8b5ad7c

Please sign in to comment.