August 2019
Beginner to intermediate
798 pages
17h 2m
English
The sync.Mutex type is the Go implementation of a mutex. Its definition, which can be found in the mutex.go file of the sync directory, is as follows:
// 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.
type Mutex struct {
state int32
sema uint32
}
The definition of the sync.Mutex type is nothing extraordinary. All of the interesting work is done by the sync.Lock() and sync.Unlock() functions, which can lock and unlock a sync.Mutex mutex, respectively. Locking a mutex means that nobody else ...
Read now
Unlock full access