Versions in this module Expand all Collapse all v1 v1.1.7 Aug 25, 2021 v1.1.6 Apr 14, 2021 Changes in this version + var ErrLimitReturn = errors.New(...) + var ErrTimeout = errors.New("borrow timeout") + var ErrUseOfCleaned = errors.New("using a cleaned resource") + func Once(fn func()) func() + type AtomicBool uint32 + func ForAtomicBool(val bool) *AtomicBool + func NewAtomicBool() *AtomicBool + func (b *AtomicBool) CompareAndSwap(old, val bool) bool + func (b *AtomicBool) Set(v bool) + func (b *AtomicBool) True() bool + type AtomicDuration int64 + func ForAtomicDuration(val time.Duration) *AtomicDuration + func NewAtomicDuration() *AtomicDuration + func (d *AtomicDuration) CompareAndSwap(old, val time.Duration) bool + func (d *AtomicDuration) Load() time.Duration + func (d *AtomicDuration) Set(val time.Duration) + type AtomicFloat64 uint64 + func ForAtomicFloat64(val float64) *AtomicFloat64 + func NewAtomicFloat64() *AtomicFloat64 + func (f *AtomicFloat64) Add(val float64) float64 + func (f *AtomicFloat64) CompareAndSwap(old, val float64) bool + func (f *AtomicFloat64) Load() float64 + func (f *AtomicFloat64) Set(val float64) + type Barrier struct + func (b *Barrier) Guard(fn func()) + type Cond struct + func NewCond() *Cond + func (cond *Cond) Signal() + func (cond *Cond) Wait() + func (cond *Cond) WaitWithTimeout(timeout time.Duration) (time.Duration, bool) + type DoneChan struct + func NewDoneChan() *DoneChan + func (dc *DoneChan) Close() + func (dc *DoneChan) Done() chan lang.PlaceholderType + type ImmutableResource struct + func NewImmutableResource(fn func() (interface{}, error), opts ...ImmutableResourceOption) *ImmutableResource + func (ir *ImmutableResource) Get() (interface{}, error) + type ImmutableResourceOption func(resource *ImmutableResource) + func WithRefreshIntervalOnFailure(interval time.Duration) ImmutableResourceOption + type Limit struct + func NewLimit(n int) Limit + func (l Limit) Borrow() + func (l Limit) Return() error + func (l Limit) TryBorrow() bool + type LockedCalls interface + Do func(key string, fn func() (interface{}, error)) (interface{}, error) + func NewLockedCalls() LockedCalls + type ManagedResource struct + func NewManagedResource(generate func() interface{}, equals func(a, b interface{}) bool) *ManagedResource + func (mr *ManagedResource) MarkBroken(resource interface{}) + func (mr *ManagedResource) Take() interface{} + type OnceGuard struct + func (og *OnceGuard) Take() bool + func (og *OnceGuard) Taken() bool + type Pool struct + func NewPool(n int, create func() interface{}, destroy func(interface{}), ...) *Pool + func (p *Pool) Get() interface{} + func (p *Pool) Put(x interface{}) + type PoolOption func(*Pool) + func WithMaxAge(duration time.Duration) PoolOption + type RefResource struct + func NewRefResource(clean func()) *RefResource + func (r *RefResource) Clean() + func (r *RefResource) Use() error + type ResourceManager struct + func NewResourceManager() *ResourceManager + func (manager *ResourceManager) Close() error + func (manager *ResourceManager) GetResource(key string, create func() (io.Closer, error)) (io.Closer, error) + type SharedCalls interface + Do func(key string, fn func() (interface{}, error)) (interface{}, error) + DoEx func(key string, fn func() (interface{}, error)) (interface{}, bool, error) + func NewSharedCalls() SharedCalls + type SpinLock struct + func (sl *SpinLock) Lock() + func (sl *SpinLock) TryLock() bool + func (sl *SpinLock) Unlock() + type TimeoutLimit struct + func NewTimeoutLimit(n int) TimeoutLimit + func (l TimeoutLimit) Borrow(timeout time.Duration) error + func (l TimeoutLimit) Return() error + func (l TimeoutLimit) TryBorrow() bool