Documentation ¶
Overview ¶
Author:ydy Date: Desc:
Author:ydy Date: Desc:
Author:ydy Date: Desc:
Author:ydy Date: Desc:
Author:ydy Date: Desc:
Author:ydy Date: Desc:
Author:ydy Date: Desc:
Author:ydy Date: Desc:
Author:ydy Date: Desc:
Author:ydy Date: Desc:
Author:ydy Date: Desc:
Author:ydy Date: Desc:
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTimeout = errors.New("borrow timeout")
ErrTimeout is an error that indicates the borrow timeout.
Functions ¶
Types ¶
type AtomicBool ¶
type AtomicBool uint32
An AtomicBool is an atomic implementation for boolean values.
func ForAtomicBool ¶
func ForAtomicBool(val bool) *AtomicBool
ForAtomicBool returns an AtomicBool with given val.
func (*AtomicBool) CompareAndSwap ¶
func (m *AtomicBool) CompareAndSwap(old, val bool) bool
CompareAndSwap compares current value with given old, if equals, set to given val.
func (*AtomicBool) Set ¶
func (m *AtomicBool) Set(val bool)
func (*AtomicBool) True ¶
func (m *AtomicBool) True() bool
type AtomicDuration ¶
type AtomicDuration int64
An AtomicDuration is an implementation of atomic duration.
func NewAtomicDuration ¶
func NewAtomicDuration() *AtomicDuration
NewAtomicDuration returns an AtomicDuration.
func (*AtomicDuration) CompareAndSwap ¶
func (m *AtomicDuration) CompareAndSwap(old, val time.Duration) bool
CompareAndSwap compares current value with old, if equals, set the value to val.
func (*AtomicDuration) ForAtomicDuration ¶
func (m *AtomicDuration) ForAtomicDuration(time time.Duration) *AtomicDuration
func (*AtomicDuration) Load ¶
func (m *AtomicDuration) Load() time.Duration
func (*AtomicDuration) Set ¶
func (m *AtomicDuration) Set(time time.Duration)
type AtomicFloat64 ¶
type AtomicFloat64 uint64
An AtomicFloat64 is an implementation of atomic float64.
func ForAtomicFloat64 ¶
func ForAtomicFloat64(val float64) *AtomicFloat64
ForAtomicFloat64 returns an AtomicFloat64 with given val.
func NewAtomicFloat64 ¶
func NewAtomicFloat64() *AtomicFloat64
NewAtomicFloat64 returns an AtomicFloat64.
func (*AtomicFloat64) Add ¶
func (m *AtomicFloat64) Add(val float64) float64
Add adds val to current value.
func (*AtomicFloat64) CompareAndSwap ¶
func (m *AtomicFloat64) CompareAndSwap(old, val float64) bool
CompareAndSwap compares current value with old, if equals, set the value to val.
func (*AtomicFloat64) Load ¶
func (m *AtomicFloat64) Load() float64
func (*AtomicFloat64) Set ¶
func (m *AtomicFloat64) Set(val float64)
type Cond ¶
type Cond struct {
// contains filtered or unexported fields
}
A Cond is used to wait for conditions.
type DoneChan ¶
type DoneChan struct {
// contains filtered or unexported fields
}
A DoneChan is used as a channel that can be closed multiple times and wait for done.
func NewDoneChan ¶
func NewDoneChan() *DoneChan
type ImmutableResource ¶
type ImmutableResource struct {
// contains filtered or unexported fields
}
An ImmutableResource is used to manage an immutable resource.
func NewImmutableResource ¶
func NewImmutableResource(fn func() (interface{}, error), opts ...ImmutableResourceOption) *ImmutableResource
func (*ImmutableResource) Get ¶
func (m *ImmutableResource) Get() (interface{}, error)
Get gets the immutable resource, fetches automatically if not loaded.
type ImmutableResourceOption ¶
type ImmutableResourceOption func(resource *ImmutableResource)
ImmutableResourceOption defines the method to customize an ImmutableResource.
func WithRefreshIntervalOnFailure ¶
func WithRefreshIntervalOnFailure(interval time.Duration) ImmutableResourceOption
WithRefreshIntervalOnFailure sets refresh interval on failure. Set interval to 0 to enforce refresh every timex if not succeeded, default is time.Second.
type Limit ¶
type Limit struct {
// contains filtered or unexported fields
}
func (Limit) TryBorrrow ¶
type OnceGuard ¶
type OnceGuard struct {
// contains filtered or unexported fields
}
A OnceGuard is used to make sure a resource can be taken once.
type SpinLock ¶
type SpinLock struct {
// contains filtered or unexported fields
}
A SpinLock is used as a lock a fast execution.
type TimeoutLimit ¶
type TimeoutLimit struct {
// contains filtered or unexported fields
}
A TimeoutLimit is used to borrow with timeouts.
func NewTimeoutLimit ¶
func NewTimeoutLimit(n int) TimeoutLimit
NewTimeoutLimit returns a TimeoutLimit.
func (*TimeoutLimit) Return ¶
func (m *TimeoutLimit) Return() error
func (*TimeoutLimit) TryBorrow ¶
func (m *TimeoutLimit) TryBorrow() bool