Documentation ¶
Index ¶
- Constants
- func RangeOption(opts ...Option) *_Option
- type Option
- type SemMap
- type SemMapper
- type Weighted
- type WideSemMap
- func (s *WideSemMap) AcquireRead(ctx context.Context, key interface{}) (*Weighted, error)
- func (s *WideSemMap) AcquireWrite(ctx context.Context, key interface{}) (*Weighted, error)
- func (s *WideSemMap) ReleaseRead(key interface{}, w *Weighted)
- func (s *WideSemMap) ReleaseWrite(key interface{}, w *Weighted)
Constants ¶
View Source
const (
//DefaultRWRatio default read/write ratio
DefaultRWRatio = 10
)
Variables ¶
This section is empty.
Functions ¶
func RangeOption ¶ added in v0.2.7
func RangeOption(opts ...Option) *_Option
RangeOption : range option
Types ¶
type Option ¶ added in v0.2.7
type Option func(o *_Option)
Option : option function
func WithRwRatio ¶ added in v0.2.7
WithRwRatio : setup read write ratio
type SemMap ¶
type SemMap struct {
// contains filtered or unexported fields
}
SemMap semaphore map
func (*SemMap) AcquireRead ¶
AcquireRead acquire for read
func (*SemMap) AcquireWrite ¶
AcquireWrite acquire for write
func (*SemMap) ReleaseRead ¶
ReleaseRead release read lock
func (*SemMap) ReleaseWrite ¶
ReleaseWrite release write lock
type SemMapper ¶
type SemMapper interface { //AcquireRead acquire for read AcquireRead(ctx context.Context, key interface{}) (*Weighted, error) //ReleaseRead release read lock ReleaseRead(key interface{}, w *Weighted) //AcquireWrite acquire for write AcquireWrite(ctx context.Context, key interface{}) (*Weighted, error) //ReleaseWrite release write lock ReleaseWrite(key interface{}, w *Weighted) }
SemMapper define interface to Acquire/Release semaphore map container
func NewWideSemMap ¶
NewWideSemMap new wide semaphore map
func NewWideXHashSemMap ¶
NewWideXHashSemMap new wide semaphore map
type Weighted ¶
type Weighted struct {
// contains filtered or unexported fields
}
Weighted provides a way to bound concurrent access to a resource. The callers can request access with a given weight.
type WideSemMap ¶
type WideSemMap struct {
// contains filtered or unexported fields
}
WideSemMap use SemMap array as wide map
func (*WideSemMap) AcquireRead ¶
func (s *WideSemMap) AcquireRead(ctx context.Context, key interface{}) (*Weighted, error)
AcquireRead acquire for read
func (*WideSemMap) AcquireWrite ¶
func (s *WideSemMap) AcquireWrite(ctx context.Context, key interface{}) (*Weighted, error)
AcquireWrite acquire for write
func (*WideSemMap) ReleaseRead ¶
func (s *WideSemMap) ReleaseRead(key interface{}, w *Weighted)
ReleaseRead release read lock
func (*WideSemMap) ReleaseWrite ¶
func (s *WideSemMap) ReleaseWrite(key interface{}, w *Weighted)
ReleaseWrite release write lock
Click to show internal directories.
Click to hide internal directories.