diff --git a/syncext/atomic.go b/syncext/atomic.go index 0e65b74..f95ad59 100644 --- a/syncext/atomic.go +++ b/syncext/atomic.go @@ -56,6 +56,12 @@ func (a *AtomicBool) Wait(waitFor bool) { } } +func (a *AtomicBool) WaitWithTimeout(timeout time.Duration, waitFor bool) error { + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + return a.WaitWithContext(ctx, waitFor) +} + func (a *AtomicBool) WaitWithContext(ctx context.Context, waitFor bool) error { if err := ctx.Err(); err != nil { return err