jonboulle / clockwork

a fake clock for golang
Apache License 2.0
656 stars 57 forks source link

Fix the NewTicker race and add regression tests. #29

Closed misterpickypants closed 4 years ago

misterpickypants commented 4 years ago

This fixes the race described by #17. The test provided in that issue is added along with another similar test that also reproduced the racy behavior.

The fix is to synchronously create the wait channel for the ticker rather that lazily create it. This must also occur on each tick: the next waiter must be initialized before the tick is sent.

Fixes https://github.com/jonboulle/clockwork/issues/17