internal

package
v0.1.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RWMutexStateUnlocked = iota
	RWMutexStateShared
	RWMutexStateExclusive
)

Variables

This section is empty.

Functions

func Sync

func Sync(path string) error

Sync performs an fsync on the given path. Typically used for directories.

Types

type RWMutex

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

RWMutex is a reader/writer mutual exclusion lock. It wraps the sync package to provide additional capabilities such as lock upgrades & downgrades. It only supports TryLock() & TryRLock() as that is what's supported by our FUSE file system.

func (*RWMutex) CanLock

func (rw *RWMutex) CanLock() bool

CanLock returns true if the write lock could be acquired.

func (*RWMutex) CanRLock

func (rw *RWMutex) CanRLock() bool

CanRLock returns true if the read lock could be acquired.

func (*RWMutex) State

func (rw *RWMutex) State() RWMutexState

State returns whether the mutex has a exclusive lock, one or more shared locks, or if the mutex is unlocked.

func (*RWMutex) TryLock

func (rw *RWMutex) TryLock() *RWMutexGuard

TryLock tries to lock the mutex for writing and returns a guard if it succeeds.

func (*RWMutex) TryRLock

func (rw *RWMutex) TryRLock() *RWMutexGuard

TryRLock tries to lock rw for reading and reports whether it succeeded.

type RWMutexGuard

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

RWMutexGuard is a reference to a held lock.

func (*RWMutexGuard) CanLock

func (g *RWMutexGuard) CanLock() bool

CanLock returns true if the guard can become an exclusive lock.

func (*RWMutexGuard) RLock

func (g *RWMutexGuard) RLock()

RLock downgrades the lock from an exclusive lock to a shared lock. This is a no-op if the lock is already a shared lock.

func (*RWMutexGuard) TryLock

func (g *RWMutexGuard) TryLock() bool

TryLock upgrades the lock from a shared lock to an exclusive lock. This is a no-op if the lock is already an exclusive lock.

func (*RWMutexGuard) Unlock

func (g *RWMutexGuard) Unlock()

Unlock unlocks the underlying mutex. Guard must be discarded after Unlock().

type RWMutexState

type RWMutexState int

RWMutexState represents the lock state of an RWMutexGuard.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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