jonboulle / clockwork

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

Only grab a read-lock in Now(). #4

Closed tsuna closed 8 years ago

tsuna commented 8 years ago

I can see two possible stances here:

  1. You consider the fakeClock non-performance sensitive test code, in which case we might just turn the RWMutex into a plain Mutex.
  2. You want to keep a RWMutex so that multiple callers can call Now() with less friction, in which case we should use RLock() / RUnlock().

I initially went with approach 1, somehow changed my mind for 2, but could be convinced either way.

jonboulle commented 8 years ago

Good spot. This is definitely my preferred approach. Thanks for the patch!