Documentation
¶
Index ¶
- type BatchError
- type Map
- func (m *Map) ComputeIfAbsent(key interface{}, computeFunc func(key interface{}) interface{}) (actual interface{}, loaded bool)
- func (m *Map) ComputeIfPresent(key interface{}, computeFunc func(key, value interface{}) interface{}) (actual interface{}, exist bool)
- func (m *Map) Delete(key interface{})
- func (m *Map) Load(key interface{}) (value interface{}, ok bool)
- func (m *Map) LoadAndDelete(key interface{}) (value interface{}, loaded bool)
- func (m *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool)
- func (m *Map) Range(f func(key, value interface{}) bool)
- func (m *Map) Store(key, value interface{})
- type Queue
- type QueueMode
- type QueueOption
- type QueueOptions
- type ResourceManager
- type Spinlock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchError ¶
type BatchError struct {
// contains filtered or unexported fields
}
A BatchError is an error that can hold multiple errors.
func (*BatchError) Err ¶
func (be *BatchError) Err() error
Err returns an error that represents all errors.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map from standard library
func (*Map) ComputeIfAbsent ¶
func (m *Map) ComputeIfAbsent(key interface{}, computeFunc func(key interface{}) interface{}) (actual interface{}, loaded bool)
ComputeIfAbsent if the value corresponding to the key does not exist, use the recalculated value obtained by remappingFunction and save it as the value of the key, otherwise return the value.
func (*Map) ComputeIfPresent ¶
func (m *Map) ComputeIfPresent(key interface{}, computeFunc func(key, value interface{}) interface{}) (actual interface{}, exist bool)
ComputeIfPresent if the value corresponding to the key does not exist, the null is returned, and if it exists, the value recalculated by remappingFunction is returned.
func (*Map) Load ¶
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 (*Map) LoadAndDelete ¶
LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
func (*Map) LoadOrStore ¶
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 (*Map) Range ¶
Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.
Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.
Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
func NewQueue ¶
func NewQueue(opts ...QueueOption) *Queue
type QueueMode ¶
type QueueMode byte
const ( MultiRead QueueMode = 1 MultiWrite QueueMode = 2 MultiReadWrite = MultiRead | MultiWrite )
type QueueOption ¶
type QueueOption func(opt *QueueOptions)
func WithQueueCap ¶
func WithQueueCap(cap int) QueueOption
func WithQueueMode ¶
func WithQueueMode(mode QueueMode) QueueOption
type QueueOptions ¶
type QueueOptions struct {
// contains filtered or unexported fields
}
type ResourceManager ¶
type ResourceManager struct {
// contains filtered or unexported fields
}
func NewResourceManager ¶
func NewResourceManager() *ResourceManager
NewResourceManager returns a ResourceManager.
func (*ResourceManager) Close ¶
func (m *ResourceManager) Close() error
Close the manager. Don't use the ResourceManager after Close() called.
func (*ResourceManager) Remove ¶
func (m *ResourceManager) Remove(key string) (exist bool)
Remove the resource associated with given key and return it if existed.