diff options
| author | 2025-10-03 15:29:41 +0200 | |
|---|---|---|
| committer | 2025-10-03 15:29:41 +0200 | |
| commit | ff950e94bb8a2e1b3c905bdba4c44d0232704b18 (patch) | |
| tree | a6aedfd6a89438f400bc20c90457552e4176f1ba /vendor/codeberg.org/gruf/go-mutexes/map.go | |
| parent | [chore] Use bulk updates + fewer loops in status rethreading migration (#4459) (diff) | |
| download | gotosocial-ff950e94bb8a2e1b3c905bdba4c44d0232704b18.tar.xz | |
[chore] update dependencies (#4468)
- github.com/ncruces/go-sqlite3
- codeberg.org/gruf/go-mempool
- codeberg.org/gruf/go-structr (changes related on the above) *
- codeberg.org/gruf/go-mutexes (changes related on the above) *
* this is largely just fiddling around with package internals in structr and mutexes to rely on changes in mempool, which added a new concurrency-safe pool
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4468
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/codeberg.org/gruf/go-mutexes/map.go')
| -rw-r--r-- | vendor/codeberg.org/gruf/go-mutexes/map.go | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/vendor/codeberg.org/gruf/go-mutexes/map.go b/vendor/codeberg.org/gruf/go-mutexes/map.go index 2f21ae0bb..e8c4d0058 100644 --- a/vendor/codeberg.org/gruf/go-mutexes/map.go +++ b/vendor/codeberg.org/gruf/go-mutexes/map.go @@ -26,14 +26,13 @@ const ( type MutexMap struct { mapmu sync.Mutex mumap hashmap - mupool mempool.UnsafePool + mupool mempool.UnsafeSimplePool } // checkInit ensures MutexMap is initialized (UNSAFE). func (mm *MutexMap) checkInit() { if mm.mumap.m == nil { mm.mumap.init(0) - mm.mupool.DirtyFactor = 256 } } @@ -175,13 +174,9 @@ func (mu *rwmutex) Lock(lt uint8) bool { // sleeping goroutines waiting on this mutex. func (mu *rwmutex) Unlock() bool { switch mu.l--; { - case mu.l > 0 && mu.t == lockTypeWrite: - panic("BUG: multiple writer locks") - case mu.l < 0: - panic("BUG: negative lock count") - case mu.l == 0: - // Fully unlocked. + // Fully + // unlock. mu.t = 0 // Awake all blocked goroutines and check @@ -197,11 +192,15 @@ func (mu *rwmutex) Unlock() bool { // (before == after) => (waiters = 0) return (before == after) - default: - // i.e. mutex still - // locked by others. - return false + case mu.l < 0: + panic("BUG: negative lock count") + case mu.t == lockTypeWrite: + panic("BUG: multiple write locks") } + + // i.e. mutex still + // locked by others. + return false } // WaitRelock expects a mutex to be passed in, already in the |
