github.com/yandex/pandora@v0.5.32/core/schedule/start_sync.go (about) 1 package schedule 2 3 import ( 4 "sync" 5 6 "go.uber.org/atomic" 7 ) 8 9 // StartSync is util to make schedule start goroutine safe. 10 // See doAtSchedule as example. 11 type StartSync struct { 12 started atomic.Bool 13 startOnce sync.Once 14 } 15 16 func (s *StartSync) IsStarted() bool { 17 return s.started.Load() 18 } 19 20 func (s *StartSync) MarkStarted() { 21 if s.started.Swap(true) { 22 panic("schedule is already started") 23 } 24 }