File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -22,18 +22,24 @@ package syscall
22
22
23
23
import (
24
24
"net"
25
+ "sync"
25
26
"time"
26
27
27
28
"google.golang.org/grpc/grpclog"
28
29
)
29
30
30
- func init () {
31
- grpclog .Info ("CPU time info is unavailable on non-linux or appengine environment." )
31
+ var once sync.Once
32
+
33
+ func log () {
34
+ once .Do (func () {
35
+ grpclog .Info ("CPU time info is unavailable on non-linux or appengine environment." )
36
+ })
32
37
}
33
38
34
39
// GetCPUTime returns the how much CPU time has passed since the start of this process.
35
40
// It always returns 0 under non-linux or appengine environment.
36
41
func GetCPUTime () int64 {
42
+ log ()
37
43
return 0
38
44
}
39
45
@@ -42,22 +48,26 @@ type Rusage struct{}
42
48
43
49
// GetRusage is a no-op function under non-linux or appengine environment.
44
50
func GetRusage () (rusage * Rusage ) {
51
+ log ()
45
52
return nil
46
53
}
47
54
48
55
// CPUTimeDiff returns the differences of user CPU time and system CPU time used
49
56
// between two Rusage structs. It a no-op function for non-linux or appengine environment.
50
57
func CPUTimeDiff (first * Rusage , latest * Rusage ) (float64 , float64 ) {
58
+ log ()
51
59
return 0 , 0
52
60
}
53
61
54
62
// SetTCPUserTimeout is a no-op function under non-linux or appengine environments
55
63
func SetTCPUserTimeout (conn net.Conn , timeout time.Duration ) error {
64
+ log ()
56
65
return nil
57
66
}
58
67
59
68
// GetTCPUserTimeout is a no-op function under non-linux or appengine environments
60
69
// a negative return value indicates the operation is not supported
61
70
func GetTCPUserTimeout (conn net.Conn ) (int , error ) {
71
+ log ()
62
72
return - 1 , nil
63
73
}
You can’t perform that action at this time.
0 commit comments