syncx

package
v2.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSpinLock

func NewSpinLock() sync.Locker

NewSpinLock creates a new spin-lock. A spin-lock calls runtime.Gosched when it failed acquiring the lock, then try again until it succeeds.

Types

type RWLock

type RWLock []rwlockShard

RWLock holds a group of sharded RWMutex, it gives better performance in read-heavy workloads by reducing lock contention, but the performance for exclusive Lock is poor.

func NewRWLock

func NewRWLock() RWLock

NewRWLock creates a new RWLock.

func (RWLock) Lock

func (p RWLock) Lock()

Lock locks all underlying mutexes, preparing for exclusive access to the resource protected by the lock.

func (RWLock) RLock

func (p RWLock) RLock() sync.Locker

RLock acquires a non-exclusive reader lock, and returns the locker. The caller must hold the returned locker and calls it's Unlock method when it finishes work with the lock.

func (RWLock) Unlock

func (p RWLock) Unlock()

Unlock releases all underlying mutexes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL