tailscale/util/ctxlock/ctx_unchecked.go
Nick Khyl a11d06d3b5
util/ctxlock: add ctxlock.Context to integrate mutex locking into context
Updates #15824
Updates #12614

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2025-05-01 14:20:45 -05:00

31 lines
606 B
Go

// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
// This file exports optimized implementation of the [Context] that omits runtime checks.
// It is used when the build tag ts_omit_ctxlock_checks is set.
//go:build ts_omit_ctxlock_checks
package ctxlock
import (
"context"
"sync"
)
type Context struct {
unchecked
}
func None() Context {
return Context{noneUnchecked}
}
func Wrap(parent context.Context) Context {
return Context{wrapUnchecked(parent)}
}
func Lock(parent Context, mu *sync.Mutex) Context {
return Context{lockUnchecked(parent.unchecked, mu)}
}