Versions in this module Expand all Collapse all v0 v0.0.1 May 17, 2022 Changes in this version + var ErrLimitReturn = errors.New(...) + var ErrTimeout = errors.New("borrow timeout") + var ErrUseOfCleaned = errors.New("using a cleaned resource") + func Guard(lock sync.Locker, fn func()) + 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) + func (manager *ResourceManager) Inject(key string, resource io.Closer) + type SingleFlight interface + Do func(key string, fn func() (interface{}, error)) (interface{}, error) + DoEx func(key string, fn func() (interface{}, error)) (interface{}, bool, error) + func NewSingleFlight() SingleFlight + 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