package sync

Import Path
	internal/sync (on go.dev)

Dependency Relation
	imports 5 packages, and imported by 2 packages

Involved Source Files hashtriemap.go Package sync provides basic synchronization primitives such as mutual exclusion locks to internal packages (including ones that depend on sync). Tests are defined in package [sync]. runtime.go
Package-Level Type Names (total 2)
/* sort by: | */
Type Parameters: K: comparable V: any HashTrieMap is an implementation of a concurrent hash-trie. The implementation is designed around frequent loads, but offers decent performance for stores and deletes as well, especially if the map is larger. Its primary use-case is the unique package, but can be used elsewhere as well. The zero HashTrieMap is empty and ready to use. It must not be copied after first use. All returns an iterator over each key and value present in the map. The iterator does not necessarily correspond to any consistent snapshot of the HashTrieMap's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently (including by yield), the iterator may reflect any mapping for that key from any point during iteration. The iterator does not block other methods on the receiver; even yield itself may call any method on the HashTrieMap. Clear deletes all the entries, resulting in an empty HashTrieMap. CompareAndDelete deletes the entry for key if its value is equal to old. The value type must be comparable, otherwise this CompareAndDelete will panic. If there is no current value for key in the map, CompareAndDelete returns false (even if the old value is the nil interface value). CompareAndSwap swaps the old and new values for key if the value stored in the map is equal to old. The value type must be of a comparable type, otherwise CompareAndSwap will panic. Delete deletes the value for a key. Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map. LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present. LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored. Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration. This exists for compatibility with sync.Map; All should be preferred. It provides the same guarantees as sync.Map, and All. Store sets the value for a key. Swap swaps the value for a key and returns the previous value if any. The loaded result reports whether the key was present.
A Mutex is a mutual exclusion lock. See package [sync.Mutex] documentation. Lock locks m. See package [sync.Mutex] documentation. TryLock tries to lock m and reports whether it succeeded. See package [sync.Mutex] documentation. Unlock unlocks m. See package [sync.Mutex] documentation. *Mutex : sync.Locker