sync

package
v1.25.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: BSD-3-Clause Imports: 1 Imported by: 1

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 synchronizes concurrent access to a code block. locker.Lock(id) defer locker.Unlock(id)

func New

func New() *KeyLocker

New 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 and it will delete it from the shared locks map

Jump to

Keyboard shortcuts

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