-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fake clock] Make Stop / Reset return false if Timer stopped (#320)
* [Fake clock] Make Stop / Reset return false if Timer stopped In order to conform to the standard library Timer, Stop and Reset should return false if the Timer has already been stopped, which was not the case previously. We add unit tests to validate the new implementation. The updated TestFakeStop test case and the new TestFakeReset/reset_stopped_timer case fail with the old implementation. We also simplify the implementation of Stop and Rest in the following way: there is no need to check f.waiter.fired to determine whether a Timer has expired. For Timers, this flag is set atomically with the waiter being removed from the waiters list. As a result, we only check for absence of the waiter from the list, which either indicates that the Timer has been stopped or that it has already expired (fired). Signed-off-by: Antonin Bas <[email protected]> * Address review comments Removed unused fired field for waiters. Signed-off-by: Antonin Bas <[email protected]> --------- Signed-off-by: Antonin Bas <[email protected]>
- Loading branch information
1 parent
6fe5fd8
commit 24370be
Showing
2 changed files
with
96 additions
and
15 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