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 ¶
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.
Types ¶
type RWMutex ¶
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.