Skip to content

Commit

Permalink
fix mutex gap (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
haitch committed Sep 7, 2022
1 parent c35056b commit f755769
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions task.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ func runAndTrackGenericTask[T any](ctx context.Context, record *Task[T], task fu

func (t *Task[T]) finish(state State, result *T, err error) {
// only update state and result if not yet canceled
if !t.finished() {
t.mutex.Lock()
t.mutex.Lock()
defer t.mutex.Unlock()
if !t.state.IsTerminalState() {
t.cancelFunc() // cancel the context
t.state = state
t.result = result
t.err = err
t.mutex.Unlock()
}
}

Expand Down

0 comments on commit f755769

Please sign in to comment.