peeridlocker

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: AGPL-3.0 Imports: 3 Imported by: 0

README

peerid-locker

peerid-locker is used to manage concurrent access to resources that are peerID specific, such as when publishing IPNS records. It enables us to lock access to a resource that is specific to a particular peerID, without blocking access to resources that are specific to other peerIDs

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerIDLocker

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

PeerIDLocker is used to handle mutex lock/unlock on a per-peerID basis for systems that may need concurrent access to peerID specific resources such as IPNS record publishing

The only time this blocks is when creating the initial lock, afterwards all writes for a record are non-blocking unless another record is first published at the same time.

func New

func New() *PeerIDLocker

New returns a fresh instance of PeerIDLocker

func (*PeerIDLocker) Create

func (pl *PeerIDLocker) Create(pid peer.ID)

Create is like exists, except it populates the map if the entry does not exist

func (*PeerIDLocker) Exists

func (pl *PeerIDLocker) Exists(pid peer.ID) bool

Exists check if we have a lock for this peerID

func (*PeerIDLocker) Lock

func (pl *PeerIDLocker) Lock(pid peer.ID)

Lock obtains a lock for the peerID

func (*PeerIDLocker) Unlock

func (pl *PeerIDLocker) Unlock(pid peer.ID)

Unlock reverts the peerID lock

Jump to

Keyboard shortcuts

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