You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
465 B
23 lines
465 B
1 year ago
|
package backend
|
||
|
|
||
|
import "sync"
|
||
|
|
||
|
// mutex still needed, see: https://github.com/ggerganov/llama.cpp/discussions/784
|
||
|
var mutexMap sync.Mutex
|
||
|
var mutexes map[string]*sync.Mutex = make(map[string]*sync.Mutex)
|
||
|
|
||
|
func Lock(s string) *sync.Mutex {
|
||
|
// This is still needed, see: https://github.com/ggerganov/llama.cpp/discussions/784
|
||
|
mutexMap.Lock()
|
||
|
l, ok := mutexes[s]
|
||
|
if !ok {
|
||
|
m := &sync.Mutex{}
|
||
|
mutexes[s] = m
|
||
|
l = m
|
||
|
}
|
||
|
mutexMap.Unlock()
|
||
|
l.Lock()
|
||
|
|
||
|
return l
|
||
|
}
|