summaryrefslogtreecommitdiff
path: root/vendor
diff options
context:
space:
mode:
Diffstat (limited to 'vendor')
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/map.go28
-rw-r--r--vendor/codeberg.org/gruf/go-mutexes/map_unsafe.go41
-rw-r--r--vendor/modules.txt2
3 files changed, 44 insertions, 27 deletions
diff --git a/vendor/codeberg.org/gruf/go-mutexes/map.go b/vendor/codeberg.org/gruf/go-mutexes/map.go
index 4b721cec4..2f21ae0bb 100644
--- a/vendor/codeberg.org/gruf/go-mutexes/map.go
+++ b/vendor/codeberg.org/gruf/go-mutexes/map.go
@@ -2,7 +2,6 @@ package mutexes
import (
"sync"
- "sync/atomic"
"unsafe"
"codeberg.org/gruf/go-mempool"
@@ -185,34 +184,11 @@ func (mu *rwmutex) Unlock() bool {
// Fully unlocked.
mu.t = 0
- // NOTE: must remain in
- // sync with runtime.notifyList{}.
- //
- // goexperiment.staticlockranking
- // does change it slightly, but
- // this does not alter the first
- // 2 fields which are all we need.
- type notifyList struct {
- _ uint32
- notify uint32
- // ... other fields
- }
-
- // NOTE: must remain in
- // sync with sync.Cond{}.
- type syncCond struct {
- _ struct{}
- L sync.Locker
- n notifyList
- // ... other fields
- }
-
// Awake all blocked goroutines and check
// for change in the last notified ticket.
- cptr := (*syncCond)(unsafe.Pointer(&mu.c))
- before := atomic.LoadUint32(&cptr.n.notify)
+ before := syncCond_last_ticket(&mu.c)
mu.c.Broadcast() // awakes all blocked!
- after := atomic.LoadUint32(&cptr.n.notify)
+ after := syncCond_last_ticket(&mu.c)
// If ticket changed, this indicates
// AT LEAST one goroutine was awoken.
diff --git a/vendor/codeberg.org/gruf/go-mutexes/map_unsafe.go b/vendor/codeberg.org/gruf/go-mutexes/map_unsafe.go
new file mode 100644
index 000000000..a59c13015
--- /dev/null
+++ b/vendor/codeberg.org/gruf/go-mutexes/map_unsafe.go
@@ -0,0 +1,41 @@
+//go:build go1.22 && !go1.25
+
+package mutexes
+
+import (
+ "sync"
+ "sync/atomic"
+ "unsafe"
+)
+
+// syncCond_last_ticket is an unsafe function that returns
+// the ticket of the last awoken / notified goroutine by a
+// a sync.Cond{}. it relies on expected memory layout.
+func syncCond_last_ticket(c *sync.Cond) uint32 {
+
+ // NOTE: must remain in
+ // sync with runtime.notifyList{}.
+ //
+ // goexperiment.staticlockranking
+ // does change it slightly, but
+ // this does not alter the first
+ // 2 fields which are all we need.
+ type notifyList struct {
+ _ atomic.Uint32
+ notify uint32
+ // ... other fields
+ }
+
+ // NOTE: must remain in
+ // sync with sync.Cond{}.
+ type syncCond struct {
+ _ struct{}
+ L sync.Locker
+ n notifyList
+ // ... other fields
+ }
+
+ // This field must be atomcially accessed.
+ cptr := (*syncCond)(unsafe.Pointer(c))
+ return atomic.LoadUint32(&cptr.n.notify)
+}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 1886a386e..d9e199f56 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -47,7 +47,7 @@ codeberg.org/gruf/go-maps
# codeberg.org/gruf/go-mempool v0.0.0-20240507125005-cef10d64a760
## explicit; go 1.22.2
codeberg.org/gruf/go-mempool
-# codeberg.org/gruf/go-mutexes v1.5.1
+# codeberg.org/gruf/go-mutexes v1.5.2
## explicit; go 1.22.2
codeberg.org/gruf/go-mutexes
# codeberg.org/gruf/go-runners v1.6.3