summaryrefslogtreecommitdiffstats
path: root/dependencies/pkg/mod/golang.org
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:41:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:41:39 +0000
commit6696b6fca647cb1fe1ce74e8127090aa61482cab (patch)
tree75c2028bfcc4d098edf4679aa5dcefcdd45da00f /dependencies/pkg/mod/golang.org
parentAdding debian version 1.1.1-2. (diff)
downloadicingadb-6696b6fca647cb1fe1ce74e8127090aa61482cab.tar.xz
icingadb-6696b6fca647cb1fe1ce74e8127090aa61482cab.zip
Merging upstream version 1.2.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dependencies/pkg/mod/golang.org')
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map.go8
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/pre_go19.go371
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/CONTRIBUTING.md (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/CONTRIBUTING.md)0
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/LICENSE (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/LICENSE)0
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/PATENTS (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/PATENTS)0
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/README.md (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/README.md)0
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/codereview.cfg (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/codereview.cfg)0
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go)3
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup_example_md5all_test.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup_example_md5all_test.go)0
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup_test.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup_test.go)0
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/go120.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/go120.go)1
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/go120_test.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/go120_test.go)1
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/pre_go120.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/pre_go120.go)1
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/go.mod (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/go.mod)2
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/semaphore/semaphore.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/semaphore/semaphore.go)42
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/semaphore/semaphore_bench_test.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/semaphore/semaphore_bench_test.go)3
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/semaphore/semaphore_example_test.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/semaphore/semaphore_example_test.go)0
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/semaphore/semaphore_test.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/semaphore/semaphore_test.go)35
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/singleflight/singleflight.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/singleflight/singleflight.go)9
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/singleflight/singleflight_test.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/singleflight/singleflight_test.go)63
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/syncmap/map.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/go19.go)6
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/syncmap/map_bench_test.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map_bench_test.go)0
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/syncmap/map_reference_test.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map_reference_test.go)0
-rw-r--r--dependencies/pkg/mod/golang.org/x/sync@v0.7.0/syncmap/map_test.go (renamed from dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map_test.go)0
24 files changed, 147 insertions, 398 deletions
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map.go b/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map.go
deleted file mode 100644
index 4b638cb..0000000
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package syncmap provides a concurrent map implementation.
-// This was the prototype for sync.Map which was added to the standard library's
-// sync package in Go 1.9. https://golang.org/pkg/sync/#Map.
-package syncmap
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/pre_go19.go b/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/pre_go19.go
deleted file mode 100644
index 5bba413..0000000
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/pre_go19.go
+++ /dev/null
@@ -1,371 +0,0 @@
-// Copyright 2016 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build !go1.9
-// +build !go1.9
-
-package syncmap
-
-import (
- "sync"
- "sync/atomic"
- "unsafe"
-)
-
-// Map is a concurrent map with amortized-constant-time loads, stores, and deletes.
-// It is safe for multiple goroutines to call a Map's methods concurrently.
-//
-// The zero Map is valid and empty.
-//
-// A Map must not be copied after first use.
-type Map struct {
- mu sync.Mutex
-
- // read contains the portion of the map's contents that are safe for
- // concurrent access (with or without mu held).
- //
- // The read field itself is always safe to load, but must only be stored with
- // mu held.
- //
- // Entries stored in read may be updated concurrently without mu, but updating
- // a previously-expunged entry requires that the entry be copied to the dirty
- // map and unexpunged with mu held.
- read atomic.Value // readOnly
-
- // dirty contains the portion of the map's contents that require mu to be
- // held. To ensure that the dirty map can be promoted to the read map quickly,
- // it also includes all of the non-expunged entries in the read map.
- //
- // Expunged entries are not stored in the dirty map. An expunged entry in the
- // clean map must be unexpunged and added to the dirty map before a new value
- // can be stored to it.
- //
- // If the dirty map is nil, the next write to the map will initialize it by
- // making a shallow copy of the clean map, omitting stale entries.
- dirty map[interface{}]*entry
-
- // misses counts the number of loads since the read map was last updated that
- // needed to lock mu to determine whether the key was present.
- //
- // Once enough misses have occurred to cover the cost of copying the dirty
- // map, the dirty map will be promoted to the read map (in the unamended
- // state) and the next store to the map will make a new dirty copy.
- misses int
-}
-
-// readOnly is an immutable struct stored atomically in the Map.read field.
-type readOnly struct {
- m map[interface{}]*entry
- amended bool // true if the dirty map contains some key not in m.
-}
-
-// expunged is an arbitrary pointer that marks entries which have been deleted
-// from the dirty map.
-var expunged = unsafe.Pointer(new(interface{}))
-
-// An entry is a slot in the map corresponding to a particular key.
-type entry struct {
- // p points to the interface{} value stored for the entry.
- //
- // If p == nil, the entry has been deleted and m.dirty == nil.
- //
- // If p == expunged, the entry has been deleted, m.dirty != nil, and the entry
- // is missing from m.dirty.
- //
- // Otherwise, the entry is valid and recorded in m.read.m[key] and, if m.dirty
- // != nil, in m.dirty[key].
- //
- // An entry can be deleted by atomic replacement with nil: when m.dirty is
- // next created, it will atomically replace nil with expunged and leave
- // m.dirty[key] unset.
- //
- // An entry's associated value can be updated by atomic replacement, provided
- // p != expunged. If p == expunged, an entry's associated value can be updated
- // only after first setting m.dirty[key] = e so that lookups using the dirty
- // map find the entry.
- p unsafe.Pointer // *interface{}
-}
-
-func newEntry(i interface{}) *entry {
- return &entry{p: unsafe.Pointer(&i)}
-}
-
-// 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.
-func (m *Map) Load(key interface{}) (value interface{}, ok bool) {
- read, _ := m.read.Load().(readOnly)
- e, ok := read.m[key]
- if !ok && read.amended {
- m.mu.Lock()
- // Avoid reporting a spurious miss if m.dirty got promoted while we were
- // blocked on m.mu. (If further loads of the same key will not miss, it's
- // not worth copying the dirty map for this key.)
- read, _ = m.read.Load().(readOnly)
- e, ok = read.m[key]
- if !ok && read.amended {
- e, ok = m.dirty[key]
- // Regardless of whether the entry was present, record a miss: this key
- // will take the slow path until the dirty map is promoted to the read
- // map.
- m.missLocked()
- }
- m.mu.Unlock()
- }
- if !ok {
- return nil, false
- }
- return e.load()
-}
-
-func (e *entry) load() (value interface{}, ok bool) {
- p := atomic.LoadPointer(&e.p)
- if p == nil || p == expunged {
- return nil, false
- }
- return *(*interface{})(p), true
-}
-
-// Store sets the value for a key.
-func (m *Map) Store(key, value interface{}) {
- read, _ := m.read.Load().(readOnly)
- if e, ok := read.m[key]; ok && e.tryStore(&value) {
- return
- }
-
- m.mu.Lock()
- read, _ = m.read.Load().(readOnly)
- if e, ok := read.m[key]; ok {
- if e.unexpungeLocked() {
- // The entry was previously expunged, which implies that there is a
- // non-nil dirty map and this entry is not in it.
- m.dirty[key] = e
- }
- e.storeLocked(&value)
- } else if e, ok := m.dirty[key]; ok {
- e.storeLocked(&value)
- } else {
- if !read.amended {
- // We're adding the first new key to the dirty map.
- // Make sure it is allocated and mark the read-only map as incomplete.
- m.dirtyLocked()
- m.read.Store(readOnly{m: read.m, amended: true})
- }
- m.dirty[key] = newEntry(value)
- }
- m.mu.Unlock()
-}
-
-// tryStore stores a value if the entry has not been expunged.
-//
-// If the entry is expunged, tryStore returns false and leaves the entry
-// unchanged.
-func (e *entry) tryStore(i *interface{}) bool {
- p := atomic.LoadPointer(&e.p)
- if p == expunged {
- return false
- }
- for {
- if atomic.CompareAndSwapPointer(&e.p, p, unsafe.Pointer(i)) {
- return true
- }
- p = atomic.LoadPointer(&e.p)
- if p == expunged {
- return false
- }
- }
-}
-
-// unexpungeLocked ensures that the entry is not marked as expunged.
-//
-// If the entry was previously expunged, it must be added to the dirty map
-// before m.mu is unlocked.
-func (e *entry) unexpungeLocked() (wasExpunged bool) {
- return atomic.CompareAndSwapPointer(&e.p, expunged, nil)
-}
-
-// storeLocked unconditionally stores a value to the entry.
-//
-// The entry must be known not to be expunged.
-func (e *entry) storeLocked(i *interface{}) {
- atomic.StorePointer(&e.p, unsafe.Pointer(i))
-}
-
-// 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.
-func (m *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool) {
- // Avoid locking if it's a clean hit.
- read, _ := m.read.Load().(readOnly)
- if e, ok := read.m[key]; ok {
- actual, loaded, ok := e.tryLoadOrStore(value)
- if ok {
- return actual, loaded
- }
- }
-
- m.mu.Lock()
- read, _ = m.read.Load().(readOnly)
- if e, ok := read.m[key]; ok {
- if e.unexpungeLocked() {
- m.dirty[key] = e
- }
- actual, loaded, _ = e.tryLoadOrStore(value)
- } else if e, ok := m.dirty[key]; ok {
- actual, loaded, _ = e.tryLoadOrStore(value)
- m.missLocked()
- } else {
- if !read.amended {
- // We're adding the first new key to the dirty map.
- // Make sure it is allocated and mark the read-only map as incomplete.
- m.dirtyLocked()
- m.read.Store(readOnly{m: read.m, amended: true})
- }
- m.dirty[key] = newEntry(value)
- actual, loaded = value, false
- }
- m.mu.Unlock()
-
- return actual, loaded
-}
-
-// tryLoadOrStore atomically loads or stores a value if the entry is not
-// expunged.
-//
-// If the entry is expunged, tryLoadOrStore leaves the entry unchanged and
-// returns with ok==false.
-func (e *entry) tryLoadOrStore(i interface{}) (actual interface{}, loaded, ok bool) {
- p := atomic.LoadPointer(&e.p)
- if p == expunged {
- return nil, false, false
- }
- if p != nil {
- return *(*interface{})(p), true, true
- }
-
- // Copy the interface after the first load to make this method more amenable
- // to escape analysis: if we hit the "load" path or the entry is expunged, we
- // shouldn't bother heap-allocating.
- ic := i
- for {
- if atomic.CompareAndSwapPointer(&e.p, nil, unsafe.Pointer(&ic)) {
- return i, false, true
- }
- p = atomic.LoadPointer(&e.p)
- if p == expunged {
- return nil, false, false
- }
- if p != nil {
- return *(*interface{})(p), true, true
- }
- }
-}
-
-// Delete deletes the value for a key.
-func (m *Map) Delete(key interface{}) {
- read, _ := m.read.Load().(readOnly)
- e, ok := read.m[key]
- if !ok && read.amended {
- m.mu.Lock()
- read, _ = m.read.Load().(readOnly)
- e, ok = read.m[key]
- if !ok && read.amended {
- delete(m.dirty, key)
- }
- m.mu.Unlock()
- }
- if ok {
- e.delete()
- }
-}
-
-func (e *entry) delete() (hadValue bool) {
- for {
- p := atomic.LoadPointer(&e.p)
- if p == nil || p == expunged {
- return false
- }
- if atomic.CompareAndSwapPointer(&e.p, p, nil) {
- return true
- }
- }
-}
-
-// Range calls f sequentially for each key and value present in the map.
-// If f returns false, range stops the iteration.
-//
-// Range does not necessarily correspond to any consistent snapshot of the Map's
-// contents: no key will be visited more than once, but if the value for any key
-// is stored or deleted concurrently, Range may reflect any mapping for that key
-// from any point during the Range call.
-//
-// Range may be O(N) with the number of elements in the map even if f returns
-// false after a constant number of calls.
-func (m *Map) Range(f func(key, value interface{}) bool) {
- // We need to be able to iterate over all of the keys that were already
- // present at the start of the call to Range.
- // If read.amended is false, then read.m satisfies that property without
- // requiring us to hold m.mu for a long time.
- read, _ := m.read.Load().(readOnly)
- if read.amended {
- // m.dirty contains keys not in read.m. Fortunately, Range is already O(N)
- // (assuming the caller does not break out early), so a call to Range
- // amortizes an entire copy of the map: we can promote the dirty copy
- // immediately!
- m.mu.Lock()
- read, _ = m.read.Load().(readOnly)
- if read.amended {
- read = readOnly{m: m.dirty}
- m.read.Store(read)
- m.dirty = nil
- m.misses = 0
- }
- m.mu.Unlock()
- }
-
- for k, e := range read.m {
- v, ok := e.load()
- if !ok {
- continue
- }
- if !f(k, v) {
- break
- }
- }
-}
-
-func (m *Map) missLocked() {
- m.misses++
- if m.misses < len(m.dirty) {
- return
- }
- m.read.Store(readOnly{m: m.dirty})
- m.dirty = nil
- m.misses = 0
-}
-
-func (m *Map) dirtyLocked() {
- if m.dirty != nil {
- return
- }
-
- read, _ := m.read.Load().(readOnly)
- m.dirty = make(map[interface{}]*entry, len(read.m))
- for k, e := range read.m {
- if !e.tryExpungeLocked() {
- m.dirty[k] = e
- }
- }
-}
-
-func (e *entry) tryExpungeLocked() (isExpunged bool) {
- p := atomic.LoadPointer(&e.p)
- for p == nil {
- if atomic.CompareAndSwapPointer(&e.p, nil, expunged) {
- return true
- }
- p = atomic.LoadPointer(&e.p)
- }
- return p == expunged
-}
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/CONTRIBUTING.md b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/CONTRIBUTING.md
index d0485e8..d0485e8 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/CONTRIBUTING.md
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/CONTRIBUTING.md
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/LICENSE b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/LICENSE
index 6a66aea..6a66aea 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/LICENSE
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/LICENSE
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/PATENTS b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/PATENTS
index 7330990..7330990 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/PATENTS
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/PATENTS
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/README.md b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/README.md
index 7c1c8f6..7c1c8f6 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/README.md
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/README.md
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/codereview.cfg b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/codereview.cfg
index 3f8b14b..3f8b14b 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/codereview.cfg
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/codereview.cfg
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup.go
index b18efb7..948a3ee 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup.go
@@ -4,6 +4,9 @@
// Package errgroup provides synchronization, error propagation, and Context
// cancelation for groups of goroutines working on subtasks of a common task.
+//
+// [errgroup.Group] is related to [sync.WaitGroup] but adds handling of tasks
+// returning errors.
package errgroup
import (
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup_example_md5all_test.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup_example_md5all_test.go
index 739b336..739b336 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup_example_md5all_test.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup_example_md5all_test.go
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup_test.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup_test.go
index 0358842..0358842 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/errgroup_test.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup_test.go
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/go120.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/go120.go
index 7d419d3..f93c740 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/go120.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/go120.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build go1.20
-// +build go1.20
package errgroup
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/go120_test.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/go120_test.go
index 0c354a1..068f104 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/go120_test.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/go120_test.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build go1.20
-// +build go1.20
package errgroup_test
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/pre_go120.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/pre_go120.go
index 1795c18..88ce334 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/errgroup/pre_go120.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/pre_go120.go
@@ -3,7 +3,6 @@
// license that can be found in the LICENSE file.
//go:build !go1.20
-// +build !go1.20
package errgroup
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/go.mod b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/go.mod
index 782b734..74bd0ac 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/go.mod
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/go.mod
@@ -1,3 +1,3 @@
module golang.org/x/sync
-go 1.17
+go 1.18
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/semaphore/semaphore.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/semaphore/semaphore.go
index 30f632c..b618162 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/semaphore/semaphore.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/semaphore/semaphore.go
@@ -35,11 +35,25 @@ type Weighted struct {
// Acquire acquires the semaphore with a weight of n, blocking until resources
// are available or ctx is done. On success, returns nil. On failure, returns
// ctx.Err() and leaves the semaphore unchanged.
-//
-// If ctx is already done, Acquire may still succeed without blocking.
func (s *Weighted) Acquire(ctx context.Context, n int64) error {
+ done := ctx.Done()
+
s.mu.Lock()
+ select {
+ case <-done:
+ // ctx becoming done has "happened before" acquiring the semaphore,
+ // whether it became done before the call began or while we were
+ // waiting for the mutex. We prefer to fail even if we could acquire
+ // the mutex without blocking.
+ s.mu.Unlock()
+ return ctx.Err()
+ default:
+ }
if s.size-s.cur >= n && s.waiters.Len() == 0 {
+ // Since we hold s.mu and haven't synchronized since checking done, if
+ // ctx becomes done before we return here, it becoming done must have
+ // "happened concurrently" with this call - it cannot "happen before"
+ // we return in this branch. So, we're ok to always acquire here.
s.cur += n
s.mu.Unlock()
return nil
@@ -48,7 +62,7 @@ func (s *Weighted) Acquire(ctx context.Context, n int64) error {
if n > s.size {
// Don't make other Acquire calls block on one that's doomed to fail.
s.mu.Unlock()
- <-ctx.Done()
+ <-done
return ctx.Err()
}
@@ -58,14 +72,14 @@ func (s *Weighted) Acquire(ctx context.Context, n int64) error {
s.mu.Unlock()
select {
- case <-ctx.Done():
- err := ctx.Err()
+ case <-done:
s.mu.Lock()
select {
case <-ready:
- // Acquired the semaphore after we were canceled. Rather than trying to
- // fix up the queue, just pretend we didn't notice the cancelation.
- err = nil
+ // Acquired the semaphore after we were canceled.
+ // Pretend we didn't and put the tokens back.
+ s.cur -= n
+ s.notifyWaiters()
default:
isFront := s.waiters.Front() == elem
s.waiters.Remove(elem)
@@ -75,9 +89,19 @@ func (s *Weighted) Acquire(ctx context.Context, n int64) error {
}
}
s.mu.Unlock()
- return err
+ return ctx.Err()
case <-ready:
+ // Acquired the semaphore. Check that ctx isn't already done.
+ // We check the done channel instead of calling ctx.Err because we
+ // already have the channel, and ctx.Err is O(n) with the nesting
+ // depth of ctx.
+ select {
+ case <-done:
+ s.Release(n)
+ return ctx.Err()
+ default:
+ }
return nil
}
}
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/semaphore/semaphore_bench_test.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/semaphore/semaphore_bench_test.go
index 3b60ca8..aa64258 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/semaphore/semaphore_bench_test.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/semaphore/semaphore_bench_test.go
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.7
-// +build go1.7
-
package semaphore_test
import (
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/semaphore/semaphore_example_test.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/semaphore/semaphore_example_test.go
index e75cd79..e75cd79 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/semaphore/semaphore_example_test.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/semaphore/semaphore_example_test.go
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/semaphore/semaphore_test.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/semaphore/semaphore_test.go
index 6e8eca2..61012d6 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/semaphore/semaphore_test.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/semaphore/semaphore_test.go
@@ -200,3 +200,38 @@ func TestAllocCancelDoesntStarve(t *testing.T) {
}
sem.Release(1)
}
+
+func TestWeightedAcquireCanceled(t *testing.T) {
+ // https://go.dev/issue/63615
+ sem := semaphore.NewWeighted(2)
+ ctx, cancel := context.WithCancel(context.Background())
+ sem.Acquire(context.Background(), 1)
+ ch := make(chan struct{})
+ go func() {
+ // Synchronize with the Acquire(2) below.
+ for sem.TryAcquire(1) {
+ sem.Release(1)
+ }
+ // Now cancel ctx, and then release the token.
+ cancel()
+ sem.Release(1)
+ close(ch)
+ }()
+ // Since the context closing happens before enough tokens become available,
+ // this Acquire must fail.
+ if err := sem.Acquire(ctx, 2); err != context.Canceled {
+ t.Errorf("Acquire with canceled context returned wrong error: want context.Canceled, got %v", err)
+ }
+ // There must always be two tokens in the semaphore after the other
+ // goroutine releases the one we held at the start.
+ <-ch
+ if !sem.TryAcquire(2) {
+ t.Fatal("TryAcquire after canceled Acquire failed")
+ }
+ // Additionally verify that we don't acquire with a done context even when
+ // we wouldn't need to block to do so.
+ sem.Release(2)
+ if err := sem.Acquire(ctx, 1); err != context.Canceled {
+ t.Errorf("Acquire with canceled context returned wrong error: want context.Canceled, got %v", err)
+ }
+}
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/singleflight/singleflight.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/singleflight/singleflight.go
index 8473fb7..4051830 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/singleflight/singleflight.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/singleflight/singleflight.go
@@ -31,6 +31,15 @@ func (p *panicError) Error() string {
return fmt.Sprintf("%v\n\n%s", p.value, p.stack)
}
+func (p *panicError) Unwrap() error {
+ err, ok := p.value.(error)
+ if !ok {
+ return nil
+ }
+
+ return err
+}
+
func newPanicError(v interface{}) error {
stack := debug.Stack()
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/singleflight/singleflight_test.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/singleflight/singleflight_test.go
index bb25a1e..1e85b17 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/singleflight/singleflight_test.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/singleflight/singleflight_test.go
@@ -19,6 +19,69 @@ import (
"time"
)
+type errValue struct{}
+
+func (err *errValue) Error() string {
+ return "error value"
+}
+
+func TestPanicErrorUnwrap(t *testing.T) {
+ t.Parallel()
+
+ testCases := []struct {
+ name string
+ panicValue interface{}
+ wrappedErrorType bool
+ }{
+ {
+ name: "panicError wraps non-error type",
+ panicValue: &panicError{value: "string value"},
+ wrappedErrorType: false,
+ },
+ {
+ name: "panicError wraps error type",
+ panicValue: &panicError{value: new(errValue)},
+ wrappedErrorType: false,
+ },
+ }
+
+ for _, tc := range testCases {
+ tc := tc
+
+ t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
+
+ var recovered interface{}
+
+ group := &Group{}
+
+ func() {
+ defer func() {
+ recovered = recover()
+ t.Logf("after panic(%#v) in group.Do, recovered %#v", tc.panicValue, recovered)
+ }()
+
+ _, _, _ = group.Do(tc.name, func() (interface{}, error) {
+ panic(tc.panicValue)
+ })
+ }()
+
+ if recovered == nil {
+ t.Fatal("expected a non-nil panic value")
+ }
+
+ err, ok := recovered.(error)
+ if !ok {
+ t.Fatalf("recovered non-error type: %T", recovered)
+ }
+
+ if !errors.Is(err, new(errValue)) && tc.wrappedErrorType {
+ t.Errorf("unexpected wrapped error type %T; want %T", err, new(errValue))
+ }
+ })
+ }
+}
+
func TestDo(t *testing.T) {
var g Group
v, err, _ := g.Do("key", func() (interface{}, error) {
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/go19.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/syncmap/map.go
index fa04dba..c9a07f3 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/go19.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/syncmap/map.go
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build go1.9
-// +build go1.9
-
+// Package syncmap provides a concurrent map implementation.
+// This was the prototype for sync.Map which was added to the standard library's
+// sync package in Go 1.9. https://golang.org/pkg/sync/#Map.
package syncmap
import "sync" // home to the standard library's sync.map implementation as of Go 1.9
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map_bench_test.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/syncmap/map_bench_test.go
index b279b4f..b279b4f 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map_bench_test.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/syncmap/map_bench_test.go
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map_reference_test.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/syncmap/map_reference_test.go
index 923c51b..923c51b 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map_reference_test.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/syncmap/map_reference_test.go
diff --git a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map_test.go b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/syncmap/map_test.go
index bf69f50..bf69f50 100644
--- a/dependencies/pkg/mod/golang.org/x/sync@v0.3.0/syncmap/map_test.go
+++ b/dependencies/pkg/mod/golang.org/x/sync@v0.7.0/syncmap/map_test.go