You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-library/vendor/github.com/gogf/gf/v2/os/gctx/gctx_never_done.go

39 lines
1023 B

// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package gctx
import (
"context"
"time"
)
// neverDoneCtx never done.
type neverDoneCtx struct {
context.Context
}
// Done forbids the context done from parent context.
func (*neverDoneCtx) Done() <-chan struct{} {
return nil
}
// Deadline forbids the context deadline from parent context.
func (*neverDoneCtx) Deadline() (deadline time.Time, ok bool) {
return time.Time{}, false
}
// Err forbids the context done from parent context.
func (c *neverDoneCtx) Err() error {
return nil
}
// NeverDone wraps and returns a new context object that will be never done,
// which forbids the context manually done, to make the context can be propagated to asynchronous goroutines.
func NeverDone(ctx context.Context) context.Context {
return &neverDoneCtx{ctx}
}