lockorder

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lockorder locks two read-write mutexes together without risking a deadlock. It exists so that every concurrent set type in this module shares one implementation of that delicate step.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lock

func Lock(m, other *RWMutex, write bool)

Lock locks m and other for an operation that reads both of them or, if write is true, modifies m and reads other. It always locks the two in the same order, whichever way round they are passed, so concurrent calls on the same pair cannot deadlock. If m and other are the same mutex it is locked once, because taking a read lock twice can deadlock behind a waiting writer.

Pair every call with Unlock, passing the same arguments.

func Unlock

func Unlock(m, other *RWMutex, write bool)

Unlock undoes Lock.

Types

type RWMutex

type RWMutex struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

RWMutex is a sync.RWMutex that also knows its place in the global locking order. The zero value is an unlocked mutex. Like sync.RWMutex it must not be copied after first use.

Jump to

Keyboard shortcuts

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