fix some typo (#677)
This commit is contained in:
@@ -71,7 +71,7 @@ func NewQueue(producerFactory ProducerFactory, consumerFactory ConsumerFactory)
|
|||||||
return q
|
return q
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddListener adds a litener to q.
|
// AddListener adds a listener to q.
|
||||||
func (q *Queue) AddListener(listener Listener) {
|
func (q *Queue) AddListener(listener Listener) {
|
||||||
q.listeners = append(q.listeners, listener)
|
q.listeners = append(q.listeners, listener)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ var (
|
|||||||
cores uint64
|
cores uint64
|
||||||
)
|
)
|
||||||
|
|
||||||
// if /proc not present, ignore the cpu calcuation, like wsl linux
|
// if /proc not present, ignore the cpu calculation, like wsl linux
|
||||||
func init() {
|
func init() {
|
||||||
cpus, err := perCpuUsage()
|
cpus, err := perCpuUsage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func NewManagedResource(generate func() interface{}, equals func(a, b interface{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarkBroken marks the resouce broken.
|
// MarkBroken marks the resource broken.
|
||||||
func (mr *ManagedResource) MarkBroken(resource interface{}) {
|
func (mr *ManagedResource) MarkBroken(resource interface{}) {
|
||||||
mr.lock.Lock()
|
mr.lock.Lock()
|
||||||
defer mr.lock.Unlock()
|
defer mr.lock.Unlock()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package syncx
|
|||||||
|
|
||||||
import "sync"
|
import "sync"
|
||||||
|
|
||||||
// Once returns a func that guanartees fn can only called once.
|
// Once returns a func that guarantees fn can only called once.
|
||||||
func Once(fn func()) func() {
|
func Once(fn func()) func() {
|
||||||
once := new(sync.Once)
|
once := new(sync.Once)
|
||||||
return func() {
|
return func() {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package syncx
|
|||||||
|
|
||||||
import "sync/atomic"
|
import "sync/atomic"
|
||||||
|
|
||||||
// A OnceGuard is used to make sure a resouce can be taken once.
|
// A OnceGuard is used to make sure a resource can be taken once.
|
||||||
type OnceGuard struct {
|
type OnceGuard struct {
|
||||||
done uint32
|
done uint32
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type (
|
|||||||
|
|
||||||
// A Pool is used to pool resources.
|
// A Pool is used to pool resources.
|
||||||
// The difference between sync.Pool is that:
|
// The difference between sync.Pool is that:
|
||||||
// 1. the limit of the resouces
|
// 1. the limit of the resources
|
||||||
// 2. max age of the resources can be set
|
// 2. max age of the resources can be set
|
||||||
// 3. the method to destroy resources can be customized
|
// 3. the method to destroy resources can be customized
|
||||||
Pool struct {
|
Pool struct {
|
||||||
@@ -56,7 +56,7 @@ func NewPool(n int, create func() interface{}, destroy func(interface{}), opts .
|
|||||||
return pool
|
return pool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get gets a resouce.
|
// Get gets a resource.
|
||||||
func (p *Pool) Get() interface{} {
|
func (p *Pool) Get() interface{} {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
// ErrUseOfCleaned is an error that indicates using a cleaned resource.
|
// ErrUseOfCleaned is an error that indicates using a cleaned resource.
|
||||||
var ErrUseOfCleaned = errors.New("using a cleaned resource")
|
var ErrUseOfCleaned = errors.New("using a cleaned resource")
|
||||||
|
|
||||||
// A RefResource is used to reference counting a resouce.
|
// A RefResource is used to reference counting a resource.
|
||||||
type RefResource struct {
|
type RefResource struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
ref int32
|
ref int32
|
||||||
|
|||||||
Reference in New Issue
Block a user