sync

package
v0.0.0-...-f09cf9b Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyLocker

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

KeyLocker it is a thread safe wrapper of sync.Map Usage: it's used in order to lock specific key in a map to synchronize concurrent access to a code block.

locker.Lock(id)
defer locker.Unlock(id)

func NewKeyLocker

func NewKeyLocker() *KeyLocker

NewKeyLocker creates Keylocker

func (*KeyLocker) Lock

func (s *KeyLocker) Lock(ID string)

Lock it locks a specific bucket by it's ID to hold ant concurrent access to that specific item

do not forget calling Unlock() after locking it.

func (*KeyLocker) Unlock

func (s *KeyLocker) Unlock(ID string)

Unlock it unlocks a specific item by it's ID

type KeyRWLocker

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

KeyRWLocker it is a thread safe wrapper of sync.Map Usage: it's used in order to lock/rlock specific key in a map to synchronize concurrent access to a code block.

locker.Lock(id)
defer locker.Unlock(id)

or

locker.RLock(id)
defer locker.RUnlock(id)

func NewKeyRWLocker

func NewKeyRWLocker() *KeyRWLocker

NewKeyLocker creates Keylocker

func (*KeyRWLocker) Lock

func (s *KeyRWLocker) Lock(ID string)

Lock it locks a specific bucket by it's ID to hold ant concurrent access to that specific item

do not forget calling Unlock() after locking it.

func (*KeyRWLocker) RLock

func (s *KeyRWLocker) RLock(ID string)

RLock it rlocks a specific bucket by it's ID to hold ant concurrent access to that specific item

do not forget calling RUnlock() after rlocking it.

func (*KeyRWLocker) RUnlock

func (s *KeyRWLocker) RUnlock(ID string)

RUnlock it runlocks a specific item by it's ID

func (*KeyRWLocker) Unlock

func (s *KeyRWLocker) Unlock(ID string)

Unlock it unlocks a specific item by it's ID

Jump to

Keyboard shortcuts

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