mirror of
https://github.com/luxfi/utils.git
synced 2026-07-26 22:49:03 +00:00
36 lines
587 B
Go
36 lines
587 B
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package utils
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type detachedContext struct {
|
|
ctx context.Context
|
|
}
|
|
|
|
func Detach(ctx context.Context) context.Context {
|
|
return &detachedContext{
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
func (*detachedContext) Deadline() (time.Time, bool) {
|
|
return time.Time{}, false
|
|
}
|
|
|
|
func (*detachedContext) Done() <-chan struct{} {
|
|
return nil
|
|
}
|
|
|
|
func (*detachedContext) Err() error {
|
|
return nil
|
|
}
|
|
|
|
func (c *detachedContext) Value(key any) any {
|
|
return c.ctx.Value(key)
|
|
}
|