github.com/operator-framework/operator-lifecycle-manager@v0.30.0/pkg/lib/time/shared.go (about) 1 package time 2 3 import ( 4 "sync" 5 "time" 6 ) 7 8 type SharedTime struct { 9 sync.RWMutex 10 time time.Time 11 } 12 13 func (s *SharedTime) Before(other time.Time) bool { 14 s.RLock() 15 defer s.RUnlock() 16 17 return s.time.Before(other) 18 } 19 20 func (s *SharedTime) After(other time.Time) bool { 21 s.RLock() 22 defer s.RUnlock() 23 24 return !s.time.Before(other) 25 } 26 27 func (s *SharedTime) Set(current time.Time) { 28 s.Lock() 29 defer s.Unlock() 30 31 s.time = current 32 }