spinlock

package
v0.0.0-...-052ef2a Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mutex

type Mutex uint32

Mutex is used as a lock for fast critical sections.

func (*Mutex) Lock

func (sl *Mutex) Lock()

Lock locks the SpinLock.

func (*Mutex) TryLock

func (sl *Mutex) TryLock() bool

TryLock tries to lock the SpinLock.

func (*Mutex) Unlock

func (sl *Mutex) Unlock()

Unlock unlocks the SpinLock.

type RWMutex

type RWMutex struct {
	// contains filtered or unexported fields
}

An RWMutex is a reader/writer mutual exclusion lock. The lock can be held by an arbitrary number of readers or a single writer. RWMutexes can be created as part of other structures; the zero value for a RWMutex is an unlocked mutex.

func (*RWMutex) Lock

func (rw *RWMutex) Lock()

Lock locks rw for writing. If the lock is already locked for reading or writing, Lock blocks until the lock is available.

func (*RWMutex) RLock

func (rw *RWMutex) RLock()

RLock locks rw for reading.

func (*RWMutex) RLocker

func (rw *RWMutex) RLocker() sync.Locker

RLocker returns a Locker interface that implements the Lock and Unlock methods by calling rw.RLock and rw.RUnlock.

func (*RWMutex) RUnlock

func (rw *RWMutex) RUnlock()

RUnlock undoes a single RLock call; it does not affect other simultaneous readers. It is a run-time error if rw is not locked for reading on entry to RUnlock.

func (*RWMutex) TryLock

func (rw *RWMutex) TryLock() bool

TryLock tries to lock rw for writing. If the lock for writing can not be acquired immediately, false is returned.

func (*RWMutex) TryRLock

func (rw *RWMutex) TryRLock() bool

TryRLock tries to lock rw for reading. If a lock for reading can not be acquired immediately, false is returned.

func (*RWMutex) Unlock

func (rw *RWMutex) Unlock()

Unlock unlocks rw for writing. It is a run-time error if rw is not locked for writing on entry to Unlock.

As with Mutexes, a locked RWMutex is not associated with a particular goroutine. One goroutine may RLock (Lock) an RWMutex and then arrange for another goroutine to RUnlock (Unlock) it.

Jump to

Keyboard shortcuts

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