From a8bf3549b0bfe8fdf809078c53d68ade737380d5 Mon Sep 17 00:00:00 2001 From: therealpaulgg Date: Tue, 20 Feb 2024 22:12:35 -0700 Subject: [PATCH] jerk --- pkg/web/live/main.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/web/live/main.go b/pkg/web/live/main.go index ef057c1..61846fd 100644 --- a/pkg/web/live/main.go +++ b/pkg/web/live/main.go @@ -46,19 +46,18 @@ type SafeChallengeResponseDict struct { dict map[string]Something } -// Now, whenever you access ChallengeResponseDict, use the mutex to synchronize access. -// For example, when writing to the map: +// Utility method for safely writing to the dict func (c *SafeChallengeResponseDict) WriteChallenge(challengePhrase string, data Something) { - c.mux.Lock() // lock before accessing the map + c.mux.Lock() c.dict[challengePhrase] = data - c.mux.Unlock() // unlock after accessing the map + c.mux.Unlock() } -// And when reading or deleting from the map: +// Utility method for safely reading from the dict func (c *SafeChallengeResponseDict) ReadChallenge(challengePhrase string) (Something, bool) { - c.mux.Lock() // lock before accessing the map + c.mux.Lock() data, exists := c.dict[challengePhrase] - c.mux.Unlock() // unlock after accessing the map + c.mux.Unlock() return data, exists }