-
Notifications
You must be signed in to change notification settings - Fork 11
/
ref_norace.go
45 lines (35 loc) · 1007 Bytes
/
ref_norace.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (C) 2023 Storj Labs, Inc.
// See LICENSE for copying information.
//go:build !race
package leak
import "context"
// Ref implements a [Resource] tracker that is only enabled
// when compiling with `-race`.
type Ref struct {
}
// Root returns a root reference to a tracker.
func Root(skipCallers int) Ref {
return Ref{}
}
// Child returns a child ref.
func (ref Ref) Child(name string, skipCallers int) Ref {
return Ref{}
}
// StartStack returns formatted stack where the resource was created.
func (ref Ref) StartStack() string {
return ""
}
// Close closes the ref and checks whether all the children have been closed.
//
// The caller should close the ref with [Ref.Close].
func (ref Ref) Close() error {
return nil
}
// WithContext attaches a root context that handles tracking.
func WithContext(parent context.Context) (Ref, context.Context) {
return Ref{}, parent
}
// FromContext returns the attached root Ref.
func FromContext(parent context.Context) Ref {
return Ref{}
}