Skip to content

Commit

Permalink
Utilize defer
Browse files Browse the repository at this point in the history
  • Loading branch information
uudashr committed Apr 5, 2024
1 parent 0f1e73f commit 7da9708
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions future.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ func (f *Future[T]) Listen(callback SetResultFunc[T]) {
callback(f.val, f.err)
default:
f.mu.Lock()
defer f.mu.Unlock()
f.callbacks = append(f.callbacks, callback)
f.mu.Unlock()
}
}

func (f *Future[T]) notifyCallbacks() {
f.mu.Lock()
defer f.mu.Unlock()
for _, callback := range f.callbacks {
callback(f.val, f.err)
}
f.mu.Unlock()
}

// Call will converts the sync function call as async call.
Expand Down

0 comments on commit 7da9708

Please sign in to comment.