nlock

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package nlock provides a lock that can be locked n times simultaneously.

Deprecated: this can be implemented using a channel with n items.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NLock

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

An NLock is a lock that allows n holders to hold the lock simultaneously.

func New

func New(n int) *NLock

New creates a new lock for n maximum holders.

func (*NLock) Lock

func (n *NLock) Lock()

Lock locks the lock. Will block if n calls to lock were made, that were not unlocked.

func (*NLock) TryLock

func (n *NLock) TryLock() bool

TryLock attempts to obtain lock without waiting. Returns true if succeeded, or false if not.

func (*NLock) Unlock

func (n *NLock) Unlock()

Unlock releases one holder of the lock. Panics if lock has 0 holders.

Jump to

Keyboard shortcuts

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