Enha: atomic global vars instead of mutexes

This commit is contained in:
Grail Finder
2026-03-07 11:26:07 +03:00
parent a842b00e96
commit 8c4d01ab3b
4 changed files with 75 additions and 70 deletions

View File

@@ -4,14 +4,11 @@ import (
"fmt"
"strconv"
"strings"
"sync"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
var _ = sync.RWMutex{}
// Define constants for cell types
const (
CellTypeCheckbox = "checkbox"
@@ -157,9 +154,7 @@ func makePropsTable(props map[string]float32) *tview.Table {
}
// Assume local llama.cpp
refreshLocalModelsIfEmpty()
localModelsMu.RLock()
defer localModelsMu.RUnlock()
return LocalModels
return LocalModels.Load().([]string)
}
// Add input fields
addInputRow("New char to write msg as", "", func(text string) {
@@ -262,7 +257,8 @@ func makePropsTable(props map[string]float32) *tview.Table {
// Check for empty options list
if len(data.Options) == 0 {
logger.Warn("empty options list for", "label", label, "api", cfg.CurrentAPI, "localModelsLen", len(LocalModels), "orModelsLen", len(ORFreeModels))
localModels := LocalModels.Load().([]string)
logger.Warn("empty options list for", "label", label, "api", cfg.CurrentAPI, "localModelsLen", len(localModels), "orModelsLen", len(ORFreeModels))
message := "No options available for " + label
if label == "Select a model" {
switch {