當前位置: 首頁>>代碼示例>>Golang>>正文


Golang CPU.RealtimePeriod方法代碼示例

本文整理匯總了Golang中github.com/opencontainers/runtime-spec/specs-go.CPU.RealtimePeriod方法的典型用法代碼示例。如果您正苦於以下問題:Golang CPU.RealtimePeriod方法的具體用法?Golang CPU.RealtimePeriod怎麽用?Golang CPU.RealtimePeriod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/opencontainers/runtime-spec/specs-go.CPU的用法示例。


在下文中一共展示了CPU.RealtimePeriod方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: getCPUResources

func getCPUResources(config containertypes.Resources) *specs.CPU {
	cpu := specs.CPU{}

	if config.CPUShares != 0 {
		shares := uint64(config.CPUShares)
		cpu.Shares = &shares
	}

	if config.CpusetCpus != "" {
		cpuset := config.CpusetCpus
		cpu.Cpus = &cpuset
	}

	if config.CpusetMems != "" {
		cpuset := config.CpusetMems
		cpu.Mems = &cpuset
	}

	if config.NanoCPUs > 0 {
		// Use the default setting of 100ms, as is specified in:
		// https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt
		//    	cpu.cfs_period_us=100ms
		period := uint64(100 * time.Millisecond / time.Microsecond)
		quota := uint64(config.NanoCPUs) * period / 1e9
		cpu.Period = &period
		cpu.Quota = &quota
	}

	if config.CPUPeriod != 0 {
		period := uint64(config.CPUPeriod)
		cpu.Period = &period
	}

	if config.CPUQuota != 0 {
		quota := uint64(config.CPUQuota)
		cpu.Quota = &quota
	}

	if config.CPURealtimePeriod != 0 {
		period := uint64(config.CPURealtimePeriod)
		cpu.RealtimePeriod = &period
	}

	if config.CPURealtimeRuntime != 0 {
		runtime := uint64(config.CPURealtimeRuntime)
		cpu.RealtimeRuntime = &runtime
	}

	return &cpu
}
開發者ID:msabansal,項目名稱:docker,代碼行數:50,代碼來源:daemon_unix.go

示例2: getCPUResources

func getCPUResources(config containertypes.Resources) *specs.CPU {
	cpu := specs.CPU{}

	if config.CPUShares != 0 {
		shares := uint64(config.CPUShares)
		cpu.Shares = &shares
	}

	if config.CpusetCpus != "" {
		cpuset := config.CpusetCpus
		cpu.Cpus = &cpuset
	}

	if config.CpusetMems != "" {
		cpuset := config.CpusetMems
		cpu.Mems = &cpuset
	}

	if config.CPUPeriod != 0 {
		period := uint64(config.CPUPeriod)
		cpu.Period = &period
	}

	if config.CPUQuota != 0 {
		quota := uint64(config.CPUQuota)
		cpu.Quota = &quota
	}

	if config.CPURealtimePeriod != 0 {
		period := uint64(config.CPURealtimePeriod)
		cpu.RealtimePeriod = &period
	}

	if config.CPURealtimeRuntime != 0 {
		runtime := uint64(config.CPURealtimeRuntime)
		cpu.RealtimeRuntime = &runtime
	}

	return &cpu
}
開發者ID:Mic92,項目名稱:docker,代碼行數:40,代碼來源:daemon_unix.go


注:本文中的github.com/opencontainers/runtime-spec/specs-go.CPU.RealtimePeriod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。