Source File
map.go
Belonging Package
sync
package sync
import (
)
.dirty[] =
}
.storeLocked(&)
} else if , := .dirty[]; {
.storeLocked(&)
} else {
, := .read.Load().(readOnly)
if , := .m[]; {
, , := .tryLoadOrStore()
if {
return ,
}
}
.mu.Lock()
, _ = .read.Load().(readOnly)
if , := .m[]; {
if .unexpungeLocked() {
.dirty[] =
}
, , _ = .tryLoadOrStore()
} else if , := .dirty[]; {
, , _ = .tryLoadOrStore()
.missLocked()
} else {
.mu.Lock()
, _ = .read.Load().(readOnly)
if .amended {
= readOnly{m: .dirty}
.read.Store()
.dirty = nil
.misses = 0
}
.mu.Unlock()
}
for , := range .m {
, := .load()
if ! {
continue
}
if !(, ) {
break
}
}
}
func ( *Map) () {
.misses++
if .misses < len(.dirty) {
return
}
.read.Store(readOnly{m: .dirty})
.dirty = nil
.misses = 0
}
func ( *Map) () {
if .dirty != nil {
return
}
, := .read.Load().(readOnly)
.dirty = make(map[interface{}]*entry, len(.m))
for , := range .m {
if !.tryExpungeLocked() {
.dirty[] =
}
}
}
func ( *entry) () ( bool) {
:= atomic.LoadPointer(&.p)
for == nil {
if atomic.CompareAndSwapPointer(&.p, nil, expunged) {
return true
}
= atomic.LoadPointer(&.p)
}
return == expunged
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |