Documentation
¶
Index ¶
- Variables
- func Once(fn func()) func()
- type AtomicBool
- type AtomicDuration
- type AtomicFloat64
- type ConcurrentDoubleMap
- func (c *ConcurrentDoubleMap) Delete(key1, key2 string)
- func (c *ConcurrentDoubleMap) DeleteWithPlugin(key1, key2 string, plugin func())
- func (c *ConcurrentDoubleMap) DeleteWithoutLock(key1, key2 string)
- func (c *ConcurrentDoubleMap) GetShard(key string) *ConcurrentMapShared
- func (c *ConcurrentDoubleMap) Len() int32
- func (c *ConcurrentDoubleMap) Load(key1, key2 string) (interface{}, bool)
- func (c *ConcurrentDoubleMap) LoadMap(key1 string) (map[string]interface{}, bool)
- func (c *ConcurrentDoubleMap) LoadOrStore(key1, key2 string, value interface{}) (interface{}, bool)
- func (c *ConcurrentDoubleMap) Range(f func(key1, key2 string, value interface{}) bool) bool
- func (c *ConcurrentDoubleMap) RangeNextMap(key1 string, f func(key1, key2 string, value interface{}) bool) bool
- func (c *ConcurrentDoubleMap) Store(key1, key2 string, value interface{})
- func (c *ConcurrentDoubleMap) StoreWithPlugin(key1, key2 string, value interface{}, plugin func())
- type ConcurrentMap
- func (c *ConcurrentMap) Clear()
- func (c *ConcurrentMap) Delete(key string)
- func (c *ConcurrentMap) GetShard(key string) goutil.Map
- func (c *ConcurrentMap) Keys() []interface{}
- func (c *ConcurrentMap) Len() int
- func (c *ConcurrentMap) Load(key string) (interface{}, bool)
- func (c *ConcurrentMap) LoadOrStore(key string, value interface{}) (actual interface{}, loaded bool)
- func (c *ConcurrentMap) Range(f func(key, value interface{}) bool)
- func (c *ConcurrentMap) Store(key string, value interface{})
- func (c *ConcurrentMap) Values() []interface{}
- type ConcurrentMapShared
- type Cond
- type DoneChan
- type Limit
- type LockedCalls
- type ManagedResource
- type OnceGuard
- type Pool
- type PoolOption
- type RefResource
- type ResourceManager
- type SharedCalls
- type SpinLock
- type TimeoutLimit
Constants ¶
This section is empty.
Variables ¶
var ErrReturn = errors.New("discarding limited token, resource pool is full, someone returned multiple times")
var ErrTimeout = errors.New("borrow timeout")
var ErrUseOfCleaned = errors.New("using a cleaned resource")
Functions ¶
Types ¶
type AtomicBool ¶
type AtomicBool uint32
func ForAtomicBool ¶
func ForAtomicBool(val bool) *AtomicBool
func NewAtomicBool ¶
func NewAtomicBool() *AtomicBool
func (*AtomicBool) CompareAndSwap ¶
func (b *AtomicBool) CompareAndSwap(old, val bool) bool
func (*AtomicBool) Set ¶
func (b *AtomicBool) Set(v bool)
func (*AtomicBool) True ¶
func (b *AtomicBool) True() bool
type AtomicDuration ¶
type AtomicDuration int64
func ForAtomicDuration ¶
func ForAtomicDuration(val time.Duration) *AtomicDuration
func NewAtomicDuration ¶
func NewAtomicDuration() *AtomicDuration
func (*AtomicDuration) CompareAndSwap ¶
func (d *AtomicDuration) CompareAndSwap(old, val time.Duration) bool
func (*AtomicDuration) Load ¶
func (d *AtomicDuration) Load() time.Duration
func (*AtomicDuration) Set ¶
func (d *AtomicDuration) Set(val time.Duration)
type AtomicFloat64 ¶
type AtomicFloat64 uint64
func ForAtomicFloat64 ¶
func ForAtomicFloat64(val float64) *AtomicFloat64
func NewAtomicFloat64 ¶
func NewAtomicFloat64() *AtomicFloat64
func (*AtomicFloat64) Add ¶
func (f *AtomicFloat64) Add(val float64) float64
func (*AtomicFloat64) CompareAndSwap ¶
func (f *AtomicFloat64) CompareAndSwap(old, val float64) bool
func (*AtomicFloat64) Load ¶
func (f *AtomicFloat64) Load() float64
func (*AtomicFloat64) Set ¶
func (f *AtomicFloat64) Set(val float64)
type ConcurrentDoubleMap ¶
type ConcurrentDoubleMap struct {
// contains filtered or unexported fields
}
func NewConcurrentDoubleMap ¶
func NewConcurrentDoubleMap(shareCount int) *ConcurrentDoubleMap
func (*ConcurrentDoubleMap) Delete ¶
func (c *ConcurrentDoubleMap) Delete(key1, key2 string)
func (*ConcurrentDoubleMap) DeleteWithPlugin ¶
func (c *ConcurrentDoubleMap) DeleteWithPlugin(key1, key2 string, plugin func())
func (*ConcurrentDoubleMap) DeleteWithoutLock ¶
func (c *ConcurrentDoubleMap) DeleteWithoutLock(key1, key2 string)
func (*ConcurrentDoubleMap) GetShard ¶
func (c *ConcurrentDoubleMap) GetShard(key string) *ConcurrentMapShared
func (*ConcurrentDoubleMap) Load ¶
func (c *ConcurrentDoubleMap) Load(key1, key2 string) (interface{}, bool)
func (*ConcurrentDoubleMap) LoadMap ¶
func (c *ConcurrentDoubleMap) LoadMap(key1 string) (map[string]interface{}, bool)
func (*ConcurrentDoubleMap) LoadOrStore ¶
func (c *ConcurrentDoubleMap) LoadOrStore(key1, key2 string, value interface{}) (interface{}, bool)
func (*ConcurrentDoubleMap) Range ¶
func (c *ConcurrentDoubleMap) Range(f func(key1, key2 string, value interface{}) bool) bool
func (*ConcurrentDoubleMap) RangeNextMap ¶
func (c *ConcurrentDoubleMap) RangeNextMap(key1 string, f func(key1, key2 string, value interface{}) bool) bool
func (*ConcurrentDoubleMap) Store ¶
func (c *ConcurrentDoubleMap) Store(key1, key2 string, value interface{})
func (*ConcurrentDoubleMap) StoreWithPlugin ¶
func (c *ConcurrentDoubleMap) StoreWithPlugin(key1, key2 string, value interface{}, plugin func())
type ConcurrentMap ¶
type ConcurrentMap struct {
// contains filtered or unexported fields
}
func NewConcurrentMap ¶
func NewConcurrentMap(shareCount int) *ConcurrentMap
NewConcurrentMap creates a new ConcurrentMap.
func (*ConcurrentMap) Clear ¶
func (c *ConcurrentMap) Clear()
Clear clears all current data in the map.
func (*ConcurrentMap) Delete ¶
func (c *ConcurrentMap) Delete(key string)
Delete deletes the value for a key.
func (*ConcurrentMap) GetShard ¶
func (c *ConcurrentMap) GetShard(key string) goutil.Map
GetShard return a goutil.Map for a key
func (*ConcurrentMap) Load ¶
func (c *ConcurrentMap) Load(key string) (interface{}, bool)
Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.
func (*ConcurrentMap) LoadOrStore ¶
func (c *ConcurrentMap) LoadOrStore(key string, value interface{}) (actual interface{}, loaded bool)
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.
func (*ConcurrentMap) Range ¶
func (c *ConcurrentMap) Range(f func(key, value interface{}) bool)
Range traverse elements
func (*ConcurrentMap) Store ¶
func (c *ConcurrentMap) Store(key string, value interface{})
Store sets the value for a key.
func (*ConcurrentMap) Values ¶
func (c *ConcurrentMap) Values() []interface{}
Values Get all the values
type ConcurrentMapShared ¶
type ConcurrentMapShared struct {
// contains filtered or unexported fields
}
type Cond ¶
type Cond struct {
// contains filtered or unexported fields
}
type DoneChan ¶
type DoneChan struct {
// contains filtered or unexported fields
}
func NewDoneChan ¶
func NewDoneChan() *DoneChan
func (*DoneChan) Done ¶
func (dc *DoneChan) Done() chan lang.PlaceholderType
type Limit ¶
type Limit struct {
// contains filtered or unexported fields
}
type LockedCalls ¶
LockedCalls makes sure the calls with the same key to be called sequentially. For example, A called F, before it's done, B called F, then B's call would not blocked, after A's call finished, B's call got executed. The calls with the same key are independent, not sharing the returned values. A ------->calls F with key and executes<------->returns B ------------------>calls F with key<--------->executes<---->returns
func NewLockedCalls ¶
func NewLockedCalls() LockedCalls
type ManagedResource ¶
type ManagedResource struct {
// contains filtered or unexported fields
}
func NewManagedResource ¶
func NewManagedResource(generate func() interface{}, equals func(a, b interface{}) bool) *ManagedResource
func (*ManagedResource) MarkBroken ¶
func (mr *ManagedResource) MarkBroken(resource interface{})
func (*ManagedResource) Take ¶
func (mr *ManagedResource) Take() interface{}
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func NewPool ¶
func NewPool(n int, create func() interface{}, destroy func(interface{}), opts ...PoolOption) *Pool
type PoolOption ¶
type PoolOption func(*Pool)
func WithMaxAge ¶
func WithMaxAge(duration time.Duration) PoolOption
type RefResource ¶
type RefResource struct {
// contains filtered or unexported fields
}
func NewRefResource ¶
func NewRefResource(clean func()) *RefResource
func (*RefResource) Clean ¶
func (r *RefResource) Clean()
func (*RefResource) Use ¶
func (r *RefResource) Use() error
type ResourceManager ¶
type ResourceManager struct {
// contains filtered or unexported fields
}
func NewResourceManager ¶
func NewResourceManager() *ResourceManager
func (*ResourceManager) Close ¶
func (manager *ResourceManager) Close() error
func (*ResourceManager) GetResource ¶
type SharedCalls ¶
type SharedCalls interface {
}
SharedCalls lets the concurrent calls with the same key to share the call result. For example, A called F, before it's done, B called F. Then B would not execute F, and shared the result returned by F which called by A. The calls with the same key are dependent, concurrent calls share the returned values. A ------->calls F with key<------------------->returns val B --------------------->calls F with key------>returns val
func NewSharedCalls ¶
func NewSharedCalls() SharedCalls
type TimeoutLimit ¶
type TimeoutLimit struct {
// contains filtered or unexported fields
}
func NewTimeoutLimit ¶
func NewTimeoutLimit(n int) TimeoutLimit
func (TimeoutLimit) Return ¶
func (l TimeoutLimit) Return() error
func (TimeoutLimit) TryBorrow ¶
func (l TimeoutLimit) TryBorrow() bool