summaryrefslogtreecommitdiff
path: root/courses.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--courses.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/courses.go b/courses.go
index e38e2dc..454ee1c 100644
--- a/courses.go
+++ b/courses.go
@@ -34,6 +34,10 @@ type (
type courseT struct {
ID int
+ /*
+ * TODO: There will be a lot of lock contention over Selected. It is
+ * probably more appropriate to directly use atomics.
+ */
Selected int
SelectedLock sync.RWMutex
Max int
@@ -210,3 +214,10 @@ func getCourseGroupFromCourseID(ctx context.Context, courseID int) (courseGroupT
}
return ret, nil
}
+
+func (course *courseT) decrementSelectedAndPropagate() {
+ course.SelectedLock.Lock()
+ defer course.SelectedLock.Unlock()
+ course.Selected--
+ propagateIgnoreFailures(fmt.Sprintf("M %d %d", course.ID, course.Selected))
+}