mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-29 22:06:38 +08:00
23 lines
406 B
Go
23 lines
406 B
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package extpoints
|
|
|
|
import (
|
|
"slices"
|
|
"sync"
|
|
)
|
|
|
|
func unregisterEntry[T any](mu *sync.RWMutex, lookup map[string]T, list *[]T, key string, matches func(T) bool) bool {
|
|
mu.Lock()
|
|
defer mu.Unlock()
|
|
|
|
if _, exists := lookup[key]; !exists {
|
|
return false
|
|
}
|
|
|
|
delete(lookup, key)
|
|
*list = slices.DeleteFunc(*list, matches)
|
|
return true
|
|
}
|