Go Package sync: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 9: Line 9:
=Overview=
=Overview=
The <code>sync</code> package provides [[Go_Language_Goroutines#Synchronization|synchronization]] primitives to use when synchronization between [[Go_Language_Goroutines#Synchronization|goroutines]] is necessary.
The <code>sync</code> package provides [[Go_Language_Goroutines#Synchronization|synchronization]] primitives to use when synchronization between [[Go_Language_Goroutines#Synchronization|goroutines]] is necessary.
However, other than the <code>Once</code> and <code>WaitGroup</code> types, most <code>sync</code> primitives are intended for use by low-level library routines. Higher level synchronization is better done via [[Go_Channels#Overview|channels]] and communication.
=Memory Access Synchronization Primitives=
=Memory Access Synchronization Primitives=



Revision as of 23:18, 15 January 2024

External

Internal

Overview

The sync package provides synchronization primitives to use when synchronization between goroutines is necessary.

However, other than the Once and WaitGroup types, most sync primitives are intended for use by low-level library routines. Higher level synchronization is better done via channels and communication.

Memory Access Synchronization Primitives

Thread Synchronization Primitives

WaitGroup

WaitGroup

Mutex

Mutex

RWMutex

RWMutex

Once

Once

Cond

Cond