]> 127.0.0.1 Git - part/.git/commitdiff
1 v0.28.20231214145324
authorqydysky <qydysky@foxmail.com>
Thu, 14 Dec 2023 14:50:15 +0000 (22:50 +0800)
committerqydysky <qydysky@foxmail.com>
Thu, 14 Dec 2023 14:50:15 +0000 (22:50 +0800)
slice/Blocks.go

index 5de6c8a9a4c0fb9bd23b124e1834334eff3c0cf2..b3a6752ee88971bc4c0f145d058f1b1476edb470 100644 (file)
@@ -4,7 +4,7 @@ import (
        "errors"
 )
 
-type blocks[T any] struct {
+type Blocks[T any] struct {
        free chan int
        size int
        buf  []T
@@ -12,8 +12,8 @@ type blocks[T any] struct {
 
 var ErrOverflow = errors.New("ErrOverflow")
 
-func NewBlocks[T any](blockSize int, blockNum int) *blocks[T] {
-       p := &blocks[T]{
+func NewBlocks[T any](blockSize int, blockNum int) *Blocks[T] {
+       p := &Blocks[T]{
                size: blockSize,
                free: make(chan int, blockNum+1),
                buf:  make([]T, blockSize*blockNum),
@@ -31,7 +31,7 @@ func NewBlocks[T any](blockSize int, blockNum int) *blocks[T] {
 //             // do something with tmpbuf
 //             putBack()
 //     }
-func (t *blocks[T]) Get() ([]T, func(), error) {
+func (t *Blocks[T]) Get() ([]T, func(), error) {
        select {
        case offset := <-t.free:
                offset *= t.size