type Sometimes … // Do runs the function f as allowed by First, Every, and Interval. // // The model is a union (not intersection) of filters. The first call to Do // always runs f. Subsequent calls to Do run f if allowed by First or Every or // Interval. // // A non-zero First:N causes the first N Do(f) calls to run f. // // A non-zero Every:M causes every Mth Do(f) call, starting with the first, to // run f. // // A non-zero Interval causes Do(f) to run f if Interval has elapsed since // Do last ran f. // // Specifying multiple filters produces the union of these execution streams. // For example, specifying both First:N and Every:M causes the first N Do(f) // calls and every Mth Do(f) call, starting with the first, to run f. See // Examples for more. // // If Do is called multiple times simultaneously, the calls will block and run // serially. Therefore, Do is intended for lightweight operations. // // Because a call to Do may block until f returns, if f causes Do to be called, // it will deadlock. func (s *Sometimes) Do(f func()) { … }