diff --git a/go.mod b/go.mod index 75ce97ec05761..e6611a603f681 100644 --- a/go.mod +++ b/go.mod @@ -119,7 +119,7 @@ require ( github.com/IBM/ibm-cos-sdk-go v1.11.1 github.com/axiomhq/hyperloglog v0.0.0-20240507144631-af9851f82b27 github.com/buger/jsonparser v1.1.1 - github.com/coder/quartz v0.1.0 + github.com/coder/quartz v0.1.2 github.com/d4l3k/messagediff v1.2.1 github.com/dolthub/swiss v0.2.1 github.com/efficientgo/core v1.0.0-rc.3 diff --git a/go.sum b/go.sum index c47d356cc10d3..3872c63aad33a 100644 --- a/go.sum +++ b/go.sum @@ -476,8 +476,8 @@ github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78/go.mod h1:W+zGtBO5Y1Ig github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coder/quartz v0.1.0 h1:cLL+0g5l7xTf6ordRnUMMiZtRE8Sq5LxpghS63vEXrQ= -github.com/coder/quartz v0.1.0/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA= +github.com/coder/quartz v0.1.2 h1:PVhc9sJimTdKd3VbygXtS4826EOCpB1fXoRlLnCrE+s= +github.com/coder/quartz v0.1.2/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA= github.com/containerd/containerd v1.4.1/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= github.com/containerd/fifo v1.1.0 h1:4I2mbh5stb1u6ycIABlBw9zgtlK8viPI9QkQNRQEEmY= github.com/containerd/fifo v1.1.0/go.mod h1:bmC4NWMbXlt2EZ0Hc7Fx7QzTFxgPID13eH0Qu+MAb2o= diff --git a/vendor/github.com/coder/quartz/README.md b/vendor/github.com/coder/quartz/README.md index 8d467af12535e..f0703c4d7456e 100644 --- a/vendor/github.com/coder/quartz/README.md +++ b/vendor/github.com/coder/quartz/README.md @@ -73,7 +73,7 @@ For example, with a timer: ```go fired := false -tmr := mClock.Afterfunc(time.Second, func() { +tmr := mClock.AfterFunc(time.Second, func() { fired = true }) mClock.Advance(time.Second) @@ -86,7 +86,7 @@ goroutines, so _do not_ immediately assert the results: ```go fired := false -tmr := mClock.Afterfunc(time.Second, func() { +tmr := mClock.AfterFunc(time.Second, func() { fired = true }) mClock.Advance(time.Second) @@ -105,7 +105,7 @@ fired := false // set a test timeout so we don't wait the default `go test` timeout for a failure ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) -tmr := mClock.Afterfunc(time.Second, func() { +tmr := mClock.AfterFunc(time.Second, func() { fired = true }) diff --git a/vendor/github.com/coder/quartz/mock.go b/vendor/github.com/coder/quartz/mock.go index 5f97e67c4e00d..cc8e064c2172e 100644 --- a/vendor/github.com/coder/quartz/mock.go +++ b/vendor/github.com/coder/quartz/mock.go @@ -466,6 +466,8 @@ type mockTickerFunc struct { // cond is a condition Locked on the main Mock.mu cond *sync.Cond + // inProgress is true when we are actively calling f + inProgress bool // done is true when the ticker exits done bool // err holds the error when the ticker exits @@ -478,16 +480,26 @@ func (m *mockTickerFunc) next() time.Time { func (m *mockTickerFunc) fire(_ time.Time) { m.mock.mu.Lock() - defer m.mock.mu.Unlock() if m.done { + m.mock.mu.Unlock() return } m.nxt = m.nxt.Add(m.d) m.mock.recomputeNextLocked() + // we need this check to happen after we've computed the next tick, + // otherwise it will be immediately rescheduled. + if m.inProgress { + m.mock.mu.Unlock() + return + } + m.inProgress = true m.mock.mu.Unlock() err := m.f() m.mock.mu.Lock() + defer m.mock.mu.Unlock() + m.inProgress = false + m.cond.Broadcast() // wake up anything waiting for f to finish if err != nil { m.exitLocked(err) } @@ -507,6 +519,9 @@ func (m *mockTickerFunc) waitForCtx() { <-m.ctx.Done() m.mock.mu.Lock() defer m.mock.mu.Unlock() + for m.inProgress { + m.cond.Wait() + } m.exitLocked(m.ctx.Err()) } diff --git a/vendor/modules.txt b/vendor/modules.txt index 5c2359b42266b..549f624cd233f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -535,7 +535,7 @@ github.com/cncf/xds/go/xds/data/orca/v3 github.com/cncf/xds/go/xds/service/orca/v3 github.com/cncf/xds/go/xds/type/matcher/v3 github.com/cncf/xds/go/xds/type/v3 -# github.com/coder/quartz v0.1.0 +# github.com/coder/quartz v0.1.2 ## explicit; go 1.21.8 github.com/coder/quartz # github.com/containerd/fifo v1.1.0