Use taskID mutex properly

This commit is contained in:
Jesse Duffield 2024-05-26 12:25:32 +10:00
parent bca15cf6b1
commit 623fdb4f33

View file

@ -65,9 +65,12 @@ func (t *TaskManager) NewTask(f func(ctx context.Context)) error {
t.waitingMutex.Lock()
defer t.waitingMutex.Unlock()
t.taskIDMutex.Lock()
if taskID < t.newTaskId {
t.taskIDMutex.Unlock()
return
}
t.taskIDMutex.Unlock()
ctx, cancel := context.WithCancel(context.Background())
notifyStopped := make(chan struct{})