diff options
Diffstat (limited to 'courses.go')
-rw-r--r-- | courses.go | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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)) +} |