package sync

Import Path
	sync (on golang.org and go.dev)

Dependency Relation
	imports 4 packages, and imported by 68 packages

Involved Source Files
	    cond.go
	    map.go
	d-> mutex.go
	    once.go
	    pool.go
	    poolqueue.go
	    runtime.go
	    runtime2.go
	    rwmutex.go
	    waitgroup.go

Exported Type Names

type Cond (struct) Cond implements a condition variable, a rendezvous point for goroutines waiting for or announcing the occurrence of an event. Each Cond has an associated Locker L (often a *Mutex or *RWMutex), which must be held when changing the condition and when calling the Wait method. A Cond must not be copied after first use. L Locker (*T) Broadcast() (*T) Signal() (*T) Wait() func NewCond(l Locker) *Cond
type Locker (interface) A Locker represents an object that can be locked and unlocked. (T) Lock() (T) Unlock() *Mutex *RWMutex func (*RWMutex).RLocker() Locker func NewCond(l Locker) *Cond
type Map (struct) Map is like a Go map[interface{}]interface{} but is safe for concurrent use by multiple goroutines without additional locking or coordination. Loads, stores, and deletes run in amortized constant time. The Map type is specialized. Most code should use a plain Go map instead, with separate locking or coordination, for better type safety and to make it easier to maintain other invariants along with the map content. The Map type is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex. The zero Map is empty and ready for use. A Map must not be copied after first use. (*T) Delete(key interface{}) (*T) Load(key interface{}) (value interface{}, ok bool) (*T) LoadAndDelete(key interface{}) (value interface{}, loaded bool) (*T) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool) (*T) Range(f func(key, value interface{}) bool) (*T) Store(key, value interface{})
type Mutex (struct) A Mutex is a mutual exclusion lock. The zero value for a Mutex is an unlocked mutex. A Mutex must not be copied after first use. (*T) Lock() (*T) Unlock() *T : Locker
type Once (struct) Once is an object that will perform exactly one action. (*T) Do(f func())
type Pool (struct) A Pool is a set of temporary objects that may be individually saved and retrieved. Any item stored in the Pool may be removed automatically at any time without notification. If the Pool holds the only reference when this happens, the item might be deallocated. A Pool is safe for use by multiple goroutines simultaneously. Pool's purpose is to cache allocated but unused items for later reuse, relieving pressure on the garbage collector. That is, it makes it easy to build efficient, thread-safe free lists. However, it is not suitable for all free lists. An appropriate use of a Pool is to manage a group of temporary items silently shared among and potentially reused by concurrent independent clients of a package. Pool provides a way to amortize allocation overhead across many clients. An example of good use of a Pool is in the fmt package, which maintains a dynamically-sized store of temporary output buffers. The store scales under load (when many goroutines are actively printing) and shrinks when quiescent. On the other hand, a free list maintained as part of a short-lived object is not a suitable use for a Pool, since the overhead does not amortize well in that scenario. It is more efficient to have such objects implement their own free list. A Pool must not be copied after first use. New func() interface{} (*T) Get() interface{} (*T) Put(x interface{})
type RWMutex (struct) A RWMutex is a reader/writer mutual exclusion lock. The lock can be held by an arbitrary number of readers or a single writer. The zero value for a RWMutex is an unlocked mutex. A RWMutex must not be copied after first use. If a goroutine holds a RWMutex for reading and another goroutine might call Lock, no goroutine should expect to be able to acquire a read lock until the initial read lock is released. In particular, this prohibits recursive read locking. This is to ensure that the lock eventually becomes available; a blocked Lock call excludes new readers from acquiring the lock. (*T) Lock() (*T) RLock() (*T) RLocker() Locker (*T) RUnlock() (*T) Unlock() *T : Locker var syscall.ForkLock
type WaitGroup (struct) A WaitGroup waits for a collection of goroutines to finish. The main goroutine calls Add to set the number of goroutines to wait for. Then each of the goroutines runs and calls Done when finished. At the same time, Wait can be used to block until all goroutines have finished. A WaitGroup must not be copied after first use. (*T) Add(delta int) (*T) Done() (*T) Wait()
Exported Values
func NewCond(l Locker) *Cond NewCond returns a new Cond with Locker l.