![]() ContextForChannel uses a goroutine to transform a channel close to a context cancel. However, this exposes a synchronization issue if we want to unify the underlying implementation between contextless and with context - a ConditionFunc that closes the channel today expects the behavior that no subsequent conditions will be invoked (we have a test in wait_test.go TestUntilReturnsImmediately that verifies this expectation). We can't unify the implementation without ensuring this property holds. To do that this commit changes from the goroutine propagation to implementing context.Context and using stopCh as the Done(). We then implement Err() by returning context.Canceled and stub the other methods. Since our context cannot be explicitly cancelled by users, we cease to return the cancelFn and callers that need that behavior must wrap the context as normal. This should be invisible to clients - they would already observe the same behavior from the context, and the existing error behavior of Poll* is preserved (which ignores ctx.Err()). As a side effect, one less goroutine is created making it more efficient. |
||
---|---|---|
.. | ||
app | ||
controller-manager.go | ||
OWNERS |