summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--courses.go9
-rw-r--r--wsc.go2
2 files changed, 7 insertions, 4 deletions
diff --git a/courses.go b/courses.go
index 013b187..968e300 100644
--- a/courses.go
+++ b/courses.go
@@ -35,14 +35,17 @@ type (
)
type courseT struct {
- ID int
/*
* Selected is usually accessed atomically, but a lock is still
* necessary as we need to sequentialize compare-with-Max-and-increment
* operations.
+ * We put Selected before other values to ensure 64-bit alignment on
+ * all systems, because it needs to be accessed atomically. See the
+ * "Bugs" section of sync/atomic.
*/
- Selected uint32
+ Selected uint32 /* atomic */
SelectedLock sync.Mutex
+ ID int
Max uint32
Title string
Type courseTypeT
@@ -94,7 +97,7 @@ func checkCourseGroup(cg courseGroupT) bool {
var courses sync.Map /* int, *courseT */
-var numCourses uint32
+var numCourses uint32 /* atomic */
/*
* Read course information from the database. This should be called during
diff --git a/wsc.go b/wsc.go
index e2ae41e..97e649a 100644
--- a/wsc.go
+++ b/wsc.go
@@ -36,7 +36,7 @@ type errbytesT struct {
bytes *[]byte
}
-var usemCount int64
+var usemCount int64 /* atomic */
/*
* This is more appropriately typed as uint64, but it needs to be cast to int64