keylock

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package keylock is a set of mutexes addressed by a string key. Two goroutines with the same key exclude each other; different keys never wait for one another. An entry lives only while somebody holds or waits for it, so the set does not grow with the keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

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

Set is the zero-value-ready set of key mutexes.

func (*Set) Len

func (s *Set) Len() int

Len is the number of keys held or waited for now (for tests).

func (*Set) Lock

func (s *Set) Lock(key string) (unlock func())

Lock takes the mutex of key, waiting for its holder, and returns the function that releases it. The function may be called once.

Jump to

Keyboard shortcuts

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