Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayCopy(src []interface{}, srcPos int32, target []interface{}, targetPos int32, ...)
- func FillTargetElement(array []interface{}, e interface{})
- func GetPanicStack() string
- func ToJson(v interface{}) string
- type BinarySearchTree
- func (bTree *BinarySearchTree) Delete(v interface{})
- func (bTree *BinarySearchTree) Find(v interface{}) *node
- func (bTree *BinarySearchTree) FindMax() *node
- func (bTree *BinarySearchTree) FindMin() *node
- func (bTree *BinarySearchTree) FindNearbyLeft(v interface{}) *node
- func (bTree *BinarySearchTree) FindNearbyRight(v string) *node
- func (bTree *BinarySearchTree) Insert(v interface{}, replaceOld bool)
- func (bTree *BinarySearchTree) Range(call func(n *node))
- func (bTree *BinarySearchTree) SeekLevel() [][]*node
- type CSliceOption
- type CSliceOptions
- type ConcurrentMap
- func (cm *ConcurrentMap) Clear()
- func (cm *ConcurrentMap) ComputeIfAbsent(key interface{}, function func(key interface{}) interface{}) interface{}
- func (cm *ConcurrentMap) Contains(k interface{}) bool
- func (cm *ConcurrentMap) ForEach(consumer func(k, v interface{}))
- func (cm *ConcurrentMap) Get(k interface{}) interface{}
- func (cm *ConcurrentMap) Keys() []interface{}
- func (cm *ConcurrentMap) Put(k, v interface{})
- func (cm *ConcurrentMap) Remove(k interface{})
- func (cm *ConcurrentMap) Size() int
- func (cm *ConcurrentMap) Values() []interface{}
- type ConcurrentSet
- type ConcurrentSlice
- func (cs *ConcurrentSlice) Add(v interface{})
- func (cs *ConcurrentSlice) ForEach(consumer func(index int32, v interface{}))
- func (cs *ConcurrentSlice) Get(index int32) (interface{}, error)
- func (cs *ConcurrentSlice) GetFirst() interface{}
- func (cs *ConcurrentSlice) GetLast() interface{}
- func (cs *ConcurrentSlice) Remove(v interface{})
- func (cs *ConcurrentSlice) Size() int32
- type CtxFuture
- type FluxFuture
- type Future
- type HashTimeWheel
- type Job
- type MonoFuture
- type Option
- type Options
- type RoutinePool
- type Segment
- func (s *Segment) Add(e interface{})
- func (s *Segment) AddAll(src []interface{}, srcPos, size int32)
- func (s *Segment) Cap() int32
- func (s *Segment) Clear()
- func (s *Segment) Get(index int32) (interface{}, error)
- func (s *Segment) IsEmpty() bool
- func (s *Segment) IsReachEnd() bool
- func (s *Segment) PeekFirst() interface{}
- func (s *Segment) PeekLast() interface{}
- func (s *Segment) RemoveFromFirst(toIndex int32) int32
- func (s *Segment) RemoveFromFirstWhen(predicate func(v interface{}) bool) int32
- func (s *Segment) RemoveFromLastWhen(predicate func(v interface{}) bool) int32
- func (s *Segment) Size() int32
- type SegmentList
- func (sl *SegmentList) Add(e interface{})
- func (sl *SegmentList) AddAll(arr []interface{})
- func (sl *SegmentList) Clear()
- func (sl *SegmentList) Get(index int32) (interface{}, error)
- func (sl *SegmentList) GetFirst() *Segment
- func (sl *SegmentList) GetLast() *Segment
- func (sl *SegmentList) IsEmpty() bool
- func (sl *SegmentList) PeekFirst() interface{}
- func (sl *SegmentList) PeekLast() interface{}
- func (sl *SegmentList) RemoveFromFirst(toIndex int32)
- func (sl *SegmentList) RemoveFromFirstWhen(predicate func(v interface{}) bool)
- func (sl *SegmentList) RemoveFromLastWhen(predicate func(v interface{}) bool)
- func (sl *SegmentList) SegmentsSize() int32
- func (sl *SegmentList) Size() int32
- type Set
- func (s *Set) Add(value interface{})
- func (s *Set) AddAll(values ...interface{})
- func (s *Set) AddAllWithSet(set *Set)
- func (s *Set) Contain(value interface{}) bool
- func (s *Set) IsEmpty() bool
- func (s *Set) Range(f func(value interface{}))
- func (s *Set) Remove(value interface{})
- func (s *Set) RemoveAll(arr []interface{})
- func (s *Set) RemoveAllWithSet(set *Set)
- func (s *Set) RetainAll(arr ...interface{})
- func (s *Set) RetainAllWithSet(set *Set)
- func (s *Set) Size() int
- func (s *Set) ToSlice() []interface{}
- type TimeFunction
- type TreeMap
- func (tMap *TreeMap) Clear()
- func (tMap *TreeMap) ComputeIfAbsent(key interface{}, supplier func() interface{}) interface{}
- func (tMap *TreeMap) Get(key interface{}) interface{}
- func (tMap *TreeMap) IsEmpty() bool
- func (tMap *TreeMap) Put(key, val interface{})
- func (tMap *TreeMap) RangeEntry(consumer func(k, v interface{}))
- func (tMap *TreeMap) RangeLessThan(key interface{}, consumer func(k, v interface{}))
- func (tMap *TreeMap) RemoveKey(key interface{})
- func (tMap *TreeMap) Size() int64
Constants ¶
const ( SegmentShift = 7 SegmentSize = 2 << (SegmentShift - 1) )
const (
RequestID = "Pole-Request-ID"
)
Variables ¶
var EmptyBytes []byte
Functions ¶
func FillTargetElement ¶
func FillTargetElement(array []interface{}, e interface{})
Types ¶
type BinarySearchTree ¶
type BinarySearchTree struct {
// contains filtered or unexported fields
}
func NewBinarySearchTree ¶
func NewBinarySearchTree(compare func(a, b interface{}) int) *BinarySearchTree
func (*BinarySearchTree) Delete ¶
func (bTree *BinarySearchTree) Delete(v interface{})
func (*BinarySearchTree) Find ¶
func (bTree *BinarySearchTree) Find(v interface{}) *node
func (*BinarySearchTree) FindMax ¶
func (bTree *BinarySearchTree) FindMax() *node
func (*BinarySearchTree) FindMin ¶
func (bTree *BinarySearchTree) FindMin() *node
func (*BinarySearchTree) FindNearbyLeft ¶
func (bTree *BinarySearchTree) FindNearbyLeft(v interface{}) *node
5 / \ 3 8 / \ / \ 1 4 7 9
if you find 5, will return 3, if find 1, will return nil
func (*BinarySearchTree) FindNearbyRight ¶
func (bTree *BinarySearchTree) FindNearbyRight(v string) *node
5 / \ 3 8 / \ / \ 1 4 7 9
if you find 5, will return 7, if find 8, will return 9
func (*BinarySearchTree) Insert ¶
func (bTree *BinarySearchTree) Insert(v interface{}, replaceOld bool)
func (*BinarySearchTree) Range ¶
func (bTree *BinarySearchTree) Range(call func(n *node))
func (*BinarySearchTree) SeekLevel ¶
func (bTree *BinarySearchTree) SeekLevel() [][]*node
type CSliceOption ¶
type CSliceOption func(opts *CSliceOptions)
type CSliceOptions ¶
type CSliceOptions struct {
Capacity int32
}
type ConcurrentMap ¶
type ConcurrentMap struct {
// contains filtered or unexported fields
}
func NewConcurrentMap ¶
func NewConcurrentMap() *ConcurrentMap
NewConcurrentMap 创建一个新的 ConcurrentMap
func (*ConcurrentMap) ComputeIfAbsent ¶
func (cm *ConcurrentMap) ComputeIfAbsent(key interface{}, function func(key interface{}) interface{}) interface{}
ComputeIfAbsent 懒Put操作,通过 key 计算是否存在该 key,如果存在,直接返回,否则执行 function 方法计算对应的 value
func (*ConcurrentMap) Contains ¶
func (cm *ConcurrentMap) Contains(k interface{}) bool
Contains 判断是否包含某个 key
func (*ConcurrentMap) ForEach ¶
func (cm *ConcurrentMap) ForEach(consumer func(k, v interface{}))
ForEach 遍历所有的 key-value
func (*ConcurrentMap) Get ¶
func (cm *ConcurrentMap) Get(k interface{}) interface{}
Get 根据 key 获取一个数据
func (*ConcurrentMap) Remove ¶
func (cm *ConcurrentMap) Remove(k interface{})
Remove 根据 key 删除一个 key-value
func (*ConcurrentMap) Values ¶
func (cm *ConcurrentMap) Values() []interface{}
Values 获取所有的 value 数组
type ConcurrentSet ¶
type ConcurrentSet struct {
// contains filtered or unexported fields
}
func (*ConcurrentSet) Add ¶
func (s *ConcurrentSet) Add(value interface{})
func (*ConcurrentSet) Range ¶
func (s *ConcurrentSet) Range(f func(value interface{}))
func (*ConcurrentSet) Remove ¶
func (s *ConcurrentSet) Remove(value interface{})
type ConcurrentSlice ¶
type ConcurrentSlice struct {
// contains filtered or unexported fields
}
func NewConcurrentSlice ¶
func NewConcurrentSlice(opts ...CSliceOption) *ConcurrentSlice
NewConcurrentSlice 创建并发的 slice
func (*ConcurrentSlice) ForEach ¶
func (cs *ConcurrentSlice) ForEach(consumer func(index int32, v interface{}))
ForEach 遍历所有的元素
func (*ConcurrentSlice) Get ¶
func (cs *ConcurrentSlice) Get(index int32) (interface{}, error)
Get 获取某个 index 对应的元素
func (*ConcurrentSlice) GetFirst ¶
func (cs *ConcurrentSlice) GetFirst() interface{}
GetFirst 获取第一个元素
type CtxFuture ¶
type CtxFuture struct {
// contains filtered or unexported fields
}
func NewCtxFuture ¶
func NewCtxFuture(ctx context.Context, cancel context.CancelFunc) *CtxFuture
type FluxFuture ¶
type FluxFuture struct {
// contains filtered or unexported fields
}
func NewFluxFuture ¶
func NewFluxFuture(origin flux.Flux) *FluxFuture
func (*FluxFuture) Cancel ¶
func (f *FluxFuture) Cancel()
type Future ¶
type Future interface { Cancel() // contains filtered or unexported methods }
异步任务的Future持有,可以通过这个取消一个异步任务的运行
func DelaySchedule ¶
DelaySchedule 利用 time.After 实现的延迟执行
func DoTickerSchedule ¶
DoTickerSchedule 利用 time.Ticker 实现的固定周期的执行
func DoTimerSchedule ¶
DoTimerSchedule 利用 time.Timer 实现的周期执行,其中每次任务执行的间隔是可以动态调整的,通过 supplier func() time.Duration 函数 如果在 work 方法运行期间出现 panic,则无法保证任务可以继续正常执行,因此需要 work 自行 defer 去 recover 住 panic 的 Error 信息并进行处理
type HashTimeWheel ¶
type HashTimeWheel struct {
// contains filtered or unexported fields
}
func NewTimeWheel ¶
func NewTimeWheel(opt ...Option) *HashTimeWheel
func (*HashTimeWheel) DelayExec ¶
func (htw *HashTimeWheel) DelayExec(f TimeFunction, delay time.Duration) Future
DelayExec 延迟执行一个函数 f TimeFunction 任务函数 delay time.Duration : 执行延迟多久
func (*HashTimeWheel) ScheduleExec ¶
func (htw *HashTimeWheel) ScheduleExec(f TimeFunction, delay, period time.Duration) Future
ScheduleExec 定时调度执行,返回一个 Future,如果不想继续执行任务的话,就直接调用 Future.Cancel() f TimeFunction 任务函数 delay time.Duration : 首次执行延迟多久 period time.Duration : 每次任务间隔多久执行
type Job ¶
type Job struct { F func(arg interface{}) Arg interface{} // contains filtered or unexported fields }
type MonoFuture ¶
type MonoFuture struct {
// contains filtered or unexported fields
}
func NewMonoFuture ¶
func NewMonoFuture(origin mono.Mono) *MonoFuture
func (*MonoFuture) Cancel ¶
func (f *MonoFuture) Cancel()
func (*MonoFuture) IsDone ¶
func (f *MonoFuture) IsDone() bool
type RoutinePool ¶
type RoutinePool struct {
// contains filtered or unexported fields
}
var DefaultScheduler *RoutinePool = NewRoutinePool(16, 128)
func NewRoutinePool ¶
func NewRoutinePool(size, cacheSize int32) *RoutinePool
NewRoutinePool 构建一个新的协程池 size int32 协程数量 cacheSize 任务缓存通道大小
func (*RoutinePool) SetPanicHandler ¶
func (rp *RoutinePool) SetPanicHandler(panicHandler func(err interface{}))
SetPanicHandler 设置出现panic时的处理函数
type Segment ¶
type Segment struct {
// contains filtered or unexported fields
}
func NewSegment ¶
func NewSegment(owner *SegmentList) *Segment
func (*Segment) IsReachEnd ¶
func (*Segment) RemoveFromFirst ¶
func (*Segment) RemoveFromFirstWhen ¶
func (*Segment) RemoveFromLastWhen ¶
type SegmentList ¶
type SegmentList struct {
// contains filtered or unexported fields
}
func (*SegmentList) Add ¶
func (sl *SegmentList) Add(e interface{})
func (*SegmentList) AddAll ¶
func (sl *SegmentList) AddAll(arr []interface{})
func (*SegmentList) Clear ¶
func (sl *SegmentList) Clear()
func (*SegmentList) Get ¶
func (sl *SegmentList) Get(index int32) (interface{}, error)
func (*SegmentList) GetFirst ¶
func (sl *SegmentList) GetFirst() *Segment
func (*SegmentList) GetLast ¶
func (sl *SegmentList) GetLast() *Segment
func (*SegmentList) IsEmpty ¶
func (sl *SegmentList) IsEmpty() bool
func (*SegmentList) PeekFirst ¶
func (sl *SegmentList) PeekFirst() interface{}
func (*SegmentList) PeekLast ¶
func (sl *SegmentList) PeekLast() interface{}
func (*SegmentList) RemoveFromFirst ¶
func (sl *SegmentList) RemoveFromFirst(toIndex int32)
func (*SegmentList) RemoveFromFirstWhen ¶
func (sl *SegmentList) RemoveFromFirstWhen(predicate func(v interface{}) bool)
func (*SegmentList) RemoveFromLastWhen ¶
func (sl *SegmentList) RemoveFromLastWhen(predicate func(v interface{}) bool)
func (*SegmentList) SegmentsSize ¶
func (sl *SegmentList) SegmentsSize() int32
func (*SegmentList) Size ¶
func (sl *SegmentList) Size() int32
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
func NewSetWithValues ¶
func NewSetWithValues(arr ...interface{}) *Set
NewSetWithValues 根据给的数据创建一个 Set
func (*Set) RemoveAllWithSet ¶
RemoveAllWithSet 移除某些 set 里面的数据
type TimeFunction ¶
type TimeFunction interface {
Run()
}
type TreeMap ¶
type TreeMap struct { BinarySearchTree // contains filtered or unexported fields }
TreeMap 后面要优化成为红黑树,或者较为简单的 AVL 树
func NewTreeMap ¶
NewTreeMap 创建一个 TreeMap
func (*TreeMap) ComputeIfAbsent ¶
func (tMap *TreeMap) ComputeIfAbsent(key interface{}, supplier func() interface{}) interface{}
func (*TreeMap) RangeEntry ¶
func (tMap *TreeMap) RangeEntry(consumer func(k, v interface{}))
func (*TreeMap) RangeLessThan ¶
func (tMap *TreeMap) RangeLessThan(key interface{}, consumer func(k, v interface{}))