-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove data race when resetting ticker
Currently there is a data race in the Ticker that is triggered when Ticker.Reset and Ticker.IsDurationReached are called concurrently. IsDurationReached is called by the clock as part of Clock.SetTimestamp and Ticker.Reset is called by user-code. This commit fixes the data race by protecting `duration` field of Ticker with the mutex. This also forces inlining of some calls in both methods as the called methods will also attempt to lock the mutex.
- Loading branch information
Showing
2 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters