MCPcopy Index your code
hub / github.com/duke-git/lancet / Schedule

Function Schedule

function/function.go:167–186  ·  view source on GitHub ↗

Schedule invoke function every duration time, util close the returned bool channel. Play: https://go.dev/play/p/hbON-Xeyn5N

(duration time.Duration, fn any, args ...any)

Source from the content-addressed store, hash-verified

165// Schedule invoke function every duration time, util close the returned bool channel.
166// Play: https://go.dev/play/p/hbON-Xeyn5N
167func Schedule(duration time.Duration, fn any, args ...any) chan bool {
168 // Catch programming error while constructing the closure
169 mustBeFunction(fn)
170
171 quit := make(chan bool)
172
173 go func() {
174 for {
175 unsafeInvokeFunc(fn, args...)
176
177 select {
178 case <-time.After(duration):
179 case <-quit:
180 return
181 }
182 }
183 }()
184
185 return quit
186}
187
188// Pipeline takes a list of functions and returns a function whose param will be passed into
189// the functions one by one.

Callers 2

ExampleScheduleFunction · 0.85
TestScheduleFunction · 0.85

Calls 2

mustBeFunctionFunction · 0.85
unsafeInvokeFuncFunction · 0.85

Tested by 2

ExampleScheduleFunction · 0.68
TestScheduleFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…