summaryrefslogtreecommitdiff
path: root/wsm.go
diff options
context:
space:
mode:
Diffstat (limited to 'wsm.go')
-rw-r--r--wsm.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/wsm.go b/wsm.go
index 797475c..4360e75 100644
--- a/wsm.go
+++ b/wsm.go
@@ -26,6 +26,7 @@ import (
"fmt"
"strconv"
"strings"
+ "sync/atomic"
"time"
"github.com/coder/websocket"
@@ -164,8 +165,13 @@ func messageChooseCourse(
ok := func() bool {
course.SelectedLock.Lock()
defer course.SelectedLock.Unlock()
+ /*
+ * The read here doesn't have to be atomic because the
+ * lock guarantees that no other goroutine is writing to
+ * it.
+ */
if course.Selected < course.Max {
- course.Selected++
+ atomic.AddUint32(&course.Selected, 1)
return true
}
return false