gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

syscall_nonlinux.go (2016B)


      1 //go:build !linux
      2 // +build !linux
      3 
      4 /*
      5  *
      6  * Copyright 2018 gRPC authors.
      7  *
      8  * Licensed under the Apache License, Version 2.0 (the "License");
      9  * you may not use this file except in compliance with the License.
     10  * You may obtain a copy of the License at
     11  *
     12  *     http://www.apache.org/licenses/LICENSE-2.0
     13  *
     14  * Unless required by applicable law or agreed to in writing, software
     15  * distributed under the License is distributed on an "AS IS" BASIS,
     16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     17  * See the License for the specific language governing permissions and
     18  * limitations under the License.
     19  *
     20  */
     21 
     22 // Package syscall provides functionalities that grpc uses to get low-level
     23 // operating system stats/info.
     24 package syscall
     25 
     26 import (
     27 	"net"
     28 	"sync"
     29 	"time"
     30 
     31 	"google.golang.org/grpc/grpclog"
     32 )
     33 
     34 var once sync.Once
     35 var logger = grpclog.Component("core")
     36 
     37 func log() {
     38 	once.Do(func() {
     39 		logger.Info("CPU time info is unavailable on non-linux environments.")
     40 	})
     41 }
     42 
     43 // GetCPUTime returns the how much CPU time has passed since the start of this
     44 // process. It always returns 0 under non-linux environments.
     45 func GetCPUTime() int64 {
     46 	log()
     47 	return 0
     48 }
     49 
     50 // Rusage is an empty struct under non-linux environments.
     51 type Rusage struct{}
     52 
     53 // GetRusage is a no-op function under non-linux environments.
     54 func GetRusage() *Rusage {
     55 	log()
     56 	return nil
     57 }
     58 
     59 // CPUTimeDiff returns the differences of user CPU time and system CPU time used
     60 // between two Rusage structs. It a no-op function for non-linux environments.
     61 func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) {
     62 	log()
     63 	return 0, 0
     64 }
     65 
     66 // SetTCPUserTimeout is a no-op function under non-linux environments.
     67 func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error {
     68 	log()
     69 	return nil
     70 }
     71 
     72 // GetTCPUserTimeout is a no-op function under non-linux environments.
     73 // A negative return value indicates the operation is not supported
     74 func GetTCPUserTimeout(conn net.Conn) (int, error) {
     75 	log()
     76 	return -1, nil
     77 }