Documentation ¶
Index ¶
- Constants
- func IsDataLoaded(state loadStateEnum) bool
- func IsNotReleased(state loadStateEnum) bool
- type LoadStateLock
- func (ls *LoadStateLock) BlockUntilDataLoadedOrReleased()
- func (ls *LoadStateLock) PinIfNotReleased() bool
- func (ls *LoadStateLock) RLockIf(pred StatePredicate) bool
- func (ls *LoadStateLock) RUnlock()
- func (ls *LoadStateLock) StartLoadData() (LoadStateLockGuard, error)
- func (ls *LoadStateLock) StartReleaseAll() (g LoadStateLockGuard)
- func (ls *LoadStateLock) StartReleaseData() (g LoadStateLockGuard)
- func (ls *LoadStateLock) Unpin()
- type LoadStateLockGuard
- type StatePredicate
Constants ¶
const ( LoadStateOnlyMeta loadStateEnum = iota LoadStateDataLoading // There will be only one goroutine access segment when loading. LoadStateDataLoaded LoadStateDataReleasing // There will be only one goroutine access segment when releasing. LoadStateReleased )
LoadState represent the state transition of segment. LoadStateOnlyMeta: segment is created with meta, but not loaded. LoadStateDataLoading: segment is loading data. LoadStateDataLoaded: segment is full loaded, ready to be searched or queried. LoadStateDataReleasing: segment is releasing data. LoadStateReleased: segment is released. LoadStateOnlyMeta -> LoadStateDataLoading -> LoadStateDataLoaded -> LoadStateDataReleasing -> (LoadStateReleased or LoadStateOnlyMeta)
Variables ¶
This section is empty.
Functions ¶
func IsDataLoaded ¶
func IsDataLoaded(state loadStateEnum) bool
IsDataLoaded checks if the segment is loaded.
func IsNotReleased ¶
func IsNotReleased(state loadStateEnum) bool
IsNotReleased checks if the segment is not released.
Types ¶
type LoadStateLock ¶
type LoadStateLock struct {
// contains filtered or unexported fields
}
LoadStateLock is the state of segment loading.
func NewLoadStateLock ¶
func NewLoadStateLock(state loadStateEnum) *LoadStateLock
NewLoadStateLock creates a LoadState.
func (*LoadStateLock) BlockUntilDataLoadedOrReleased ¶
func (ls *LoadStateLock) BlockUntilDataLoadedOrReleased()
blockUntilDataLoadedOrReleased blocks until the segment is loaded or released.
func (*LoadStateLock) PinIfNotReleased ¶
func (ls *LoadStateLock) PinIfNotReleased() bool
PinIfNotReleased pin the segment into memory, avoid ReleaseAll to release it.
func (*LoadStateLock) RLockIf ¶
func (ls *LoadStateLock) RLockIf(pred StatePredicate) bool
RLockIfNotReleased locks the segment if the state is not released.
func (*LoadStateLock) StartLoadData ¶
func (ls *LoadStateLock) StartLoadData() (LoadStateLockGuard, error)
StartLoadData starts load segment data Fast fail if segment is not in LoadStateOnlyMeta.
func (*LoadStateLock) StartReleaseAll ¶
func (ls *LoadStateLock) StartReleaseAll() (g LoadStateLockGuard)
StartReleaseAll wait until the segment is releasable and starts releasing all segment.
func (*LoadStateLock) StartReleaseData ¶
func (ls *LoadStateLock) StartReleaseData() (g LoadStateLockGuard)
StartReleaseData wait until the segment is releasable and starts releasing segment data.
func (*LoadStateLock) Unpin ¶
func (ls *LoadStateLock) Unpin()
Unpin unpin the segment, then segment can be released by ReleaseAll.
type LoadStateLockGuard ¶
type LoadStateLockGuard interface {
Done(err error)
}
type StatePredicate ¶
type StatePredicate func(state loadStateEnum) bool