1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-04-18 08:21:03 +00:00

Get rid of concurrent map writes, once and for all

This commit is contained in:
Romein van Buren 2023-05-31 19:18:30 +02:00
parent b29502e3cc
commit 27dc1f9117
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49
2 changed files with 5 additions and 6 deletions

2
go.mod
View File

@ -53,7 +53,7 @@ require (
golang.org/x/crypto v0.1.0 // indirect golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
golang.org/x/net v0.7.0 // indirect golang.org/x/net v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect golang.org/x/sync v0.1.0
golang.org/x/sys v0.7.0 // indirect golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect golang.org/x/text v0.9.0 // indirect
) )

View File

@ -14,6 +14,7 @@ import (
"github.com/garraflavatra/rolens/internal/ui" "github.com/garraflavatra/rolens/internal/ui"
"github.com/ncruces/zenity" "github.com/ncruces/zenity"
wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime" wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime"
"golang.org/x/sync/syncmap"
) )
type EnvironmentInfo struct { type EnvironmentInfo struct {
@ -32,15 +33,13 @@ type EnvironmentInfo struct {
type App struct { type App struct {
Env EnvironmentInfo Env EnvironmentInfo
State map[string]string State syncmap.Map
ctx context.Context ctx context.Context
ui *ui.UI ui *ui.UI
} }
func NewApp() *App { func NewApp() *App {
a := &App{ a := &App{}
State: make(map[string]string),
}
_, err := exec.LookPath("mongodump") _, err := exec.LookPath("mongodump")
a.Env.HasMongoDump = err == nil a.Env.HasMongoDump = err == nil
@ -119,6 +118,6 @@ func (a *App) PurgeLogDirectory() {
} }
func (a *App) ReportSharedStateVariable(key, value string) { func (a *App) ReportSharedStateVariable(key, value string) {
a.State[key] = value a.State.Store(key, value)
wailsRuntime.LogDebug(a.ctx, fmt.Sprintf("State: %s=\"%s\"", key, value)) wailsRuntime.LogDebug(a.ctx, fmt.Sprintf("State: %s=\"%s\"", key, value))
} }