Dreamine.Threading 1.0.1
이 패키지는 .NET ThreadPool이나 Task Parallel Library를 대체하려는 목적이 아닙니다.
로딩중...
검색중...
일치하는것 없음
AdaptiveCpuCyclePolicy.cs
이 파일의 문서화 페이지로 가기
3
5
15{
25
51 {
52 _cpuUsageProvider = cpuUsageProvider ?? throw new ArgumentNullException(nameof(cpuUsageProvider));
53 }
54
103 public int GetDelayMs(
104 DreamineThreadOptions options,
107 {
108 ArgumentNullException.ThrowIfNull(options);
109 ArgumentNullException.ThrowIfNull(assignment);
110 ArgumentNullException.ThrowIfNull(context);
111
112 if (assignment.IsOverflowPolling)
113 {
114 return options.OverflowPollingIntervalMs < 0
115 ? 100
117 }
118
119 if (options.IntervalMs > 0)
120 {
121 return options.IntervalMs;
122 }
123
124 if (options.IntervalMs < 0)
125 {
126 return 10;
127 }
128
129 if (!options.UseAdaptiveCpuDelay)
130 {
131 return 0;
132 }
133
134 var cpuUsage = _cpuUsageProvider.GetTotalCpuUsagePercent();
135
136 if (cpuUsage >= 70)
137 {
138 return 5;
139 }
140
141 if (cpuUsage >= 50)
142 {
143 return 3;
144 }
145
146 if (cpuUsage >= 30)
147 {
148 return 1;
149 }
150
151 return 0;
152 }
153}
AdaptiveCpuCyclePolicy(ICpuUsageProvider cpuUsageProvider)
int GetDelayMs(DreamineThreadOptions options, DreamineThreadCoreAssignment assignment, DreamineThreadCycleContext context)