blob: 8a22729b9317cea53208b7c785fab5f1409942df [file] [edit]
// Copyright 2019 Google LLC
//
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package exec
import (
"context"
"time"
)
// withoutCancelContext is a context.Context implementation which is not
// cancelable, even if the parent context is canceled.
type withoutCancelContext struct {
context.Context
}
// Deadline implements the context.Context interface.
func (ctx *withoutCancelContext) Deadline() (time.Time, bool) {
return time.Time{}, false
}
// Done implements the context.Context interface.
func (ctx *withoutCancelContext) Done() <-chan struct{} {
return nil
}
// Err implements the context.Context interface.
func (ctx *withoutCancelContext) Err() error {
return nil
}
// withoutCancel returns a context.Context which cannot be canceled, even
// if its parent is canceled.
func withoutCancel(ctx context.Context) context.Context {
return &withoutCancelContext{ctx}
}