Dreamine.Threading 1.0.1
이 패키지는 .NET ThreadPool이나 Task Parallel Library를 대체하려는 목적이 아닙니다.
로딩중...
검색중...
일치하는것 없음
Dreamine.Threading.Allocators.AutoCoreAllocator 클래스 참조sealed

더 자세히 ...

Dreamine.Threading.Allocators.AutoCoreAllocator에 대한 상속 다이어그램 :
Dreamine.Threading.Allocators.AutoCoreAllocator에 대한 협력 다이어그램:

Public 멤버 함수

 AutoCoreAllocator ()
 AutoCoreAllocator (int logicalCoreCount)
DreamineThreadCoreAssignment Allocate (DreamineThreadOptions options)
void Release (DreamineThreadCoreAssignment assignment)

Private 멤버 함수

DreamineThreadCoreAssignment AllocateManual (DreamineThreadOptions options)
DreamineThreadCoreAssignment AllocateAuto (DreamineThreadOptions options)

Private 속성

readonly object _syncRoot = new()
readonly int _logicalCoreCount
readonly int[] _assignedCounts

상세한 설명

코어별 용량 정책을 사용해 Dreamine 작업자 스레드에 CPU 코어를 자동 할당합니다.

AutoCoreAllocator.cs 파일의 14 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ AutoCoreAllocator() [1/2]

Dreamine.Threading.Allocators.AutoCoreAllocator.AutoCoreAllocator ( )
inline

현재 환경의 논리 프로세서 수로 T:Dreamine.Threading.Allocators.AutoCoreAllocator 클래스의 새 인스턴스를 초기화합니다.

AutoCoreAllocator.cs 파일의 52 번째 라인에서 정의되었습니다.

53 : this(Environment.ProcessorCount)
54 {
55 }

◆ AutoCoreAllocator() [2/2]

Dreamine.Threading.Allocators.AutoCoreAllocator.AutoCoreAllocator ( int logicalCoreCount)
inline

지정한 논리 코어 수로 T:Dreamine.Threading.Allocators.AutoCoreAllocator 클래스의 새 인스턴스를 초기화합니다.

매개변수
logicalCoreCount사용할 논리 CPU 코어 수이며 0 이하는 1로 보정됩니다.

AutoCoreAllocator.cs 파일의 73 번째 라인에서 정의되었습니다.

74 {
75 _logicalCoreCount = logicalCoreCount <= 0 ? 1 : logicalCoreCount;
76 _assignedCounts = new int[_logicalCoreCount];
77 }

다음을 참조함 : _assignedCounts, _logicalCoreCount.

멤버 함수 문서화

◆ Allocate()

DreamineThreadCoreAssignment Dreamine.Threading.Allocators.AutoCoreAllocator.Allocate ( DreamineThreadOptions options)
inline

정규화된 스레드 옵션의 코어 모드에 따라 코어 할당을 생성합니다.

매개변수
options코어 모드와 용량 설정을 포함하는 스레드 옵션입니다.
반환값
비선호도, 수동, 자동 또는 오버플로 코어 할당입니다.
예외
ArgumentNullExceptionoptionsnull일 때 발생합니다.
ArgumentOutOfRangeException수동 코어 인덱스가 논리 코어 범위를 벗어날 때 발생합니다.

Dreamine.Threading.Interfaces.IThreadCoreAllocator를 구현.

AutoCoreAllocator.cs 파일의 119 번째 라인에서 정의되었습니다.

120 {
121 ArgumentNullException.ThrowIfNull(options);
122
123 var normalized = options.Normalize();
124
125 lock (_syncRoot)
126 {
127 return normalized.CoreMode switch
128 {
129 DreamineThreadCoreMode.None => DreamineThreadCoreAssignment.None(),
130 DreamineThreadCoreMode.Manual => AllocateManual(normalized),
131 DreamineThreadCoreMode.Auto => AllocateAuto(normalized),
132 _ => DreamineThreadCoreAssignment.None()
133 };
134 }
135 }

다음을 참조함 : _syncRoot, AllocateAuto(), AllocateManual(), Dreamine.Threading.Models.Auto, Dreamine.Threading.Models.Manual, Dreamine.Threading.Models.DreamineThreadCoreAssignment.None(), Dreamine.Threading.Models.None, Dreamine.Threading.Models.DreamineThreadOptions.Normalize().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ AllocateAuto()

DreamineThreadCoreAssignment Dreamine.Threading.Allocators.AutoCoreAllocator.AllocateAuto ( DreamineThreadOptions options)
inlineprivate

사용 카운트가 가장 낮은 코어를 선택하고 용량이 가득 차면 오버플로 할당을 반환합니다.

매개변수
options코어당 최대 스레드 수를 포함하는 정규화된 옵션입니다.
반환값
자동 전용 또는 오버플로 할당입니다.

AutoCoreAllocator.cs 파일의 262 번째 라인에서 정의되었습니다.

263 {
264 var maxPerCore = options.AutoThreadsPerCore <= 0 ? 2 : options.AutoThreadsPerCore;
265
266 var selectedCore = 0;
267 var selectedCount = _assignedCounts[0];
268
269 for (var i = 1; i < _assignedCounts.Length; i++)
270 {
271 if (_assignedCounts[i] < selectedCount)
272 {
273 selectedCore = i;
274 selectedCount = _assignedCounts[i];
275 }
276 }
277
278 if (selectedCount >= maxPerCore)
279 {
280 return DreamineThreadCoreAssignment.Overflow();
281 }
282
283 _assignedCounts[selectedCore]++;
284 return DreamineThreadCoreAssignment.Dedicated(selectedCore, true);
285 }

다음을 참조함 : _assignedCounts, Dreamine.Threading.Models.DreamineThreadOptions.AutoThreadsPerCore, Dreamine.Threading.Models.DreamineThreadCoreAssignment.Dedicated(), Dreamine.Threading.Models.DreamineThreadCoreAssignment.Overflow().

다음에 의해서 참조됨 : Allocate().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ AllocateManual()

DreamineThreadCoreAssignment Dreamine.Threading.Allocators.AutoCoreAllocator.AllocateManual ( DreamineThreadOptions options)
inlineprivate

유효성을 검사한 수동 코어 할당을 만들고 사용 카운트를 증가시킵니다.

매개변수
options수동 코어 인덱스를 포함하는 정규화된 옵션입니다.
반환값
수동 전용 할당이며 인덱스가 없으면 비선호도 할당입니다.
예외
ArgumentOutOfRangeException코어 인덱스가 논리 코어 범위를 벗어날 때 발생합니다.

AutoCoreAllocator.cs 파일의 218 번째 라인에서 정의되었습니다.

219 {
220 if (options.CoreIndex is null)
221 {
222 return DreamineThreadCoreAssignment.None();
223 }
224
225 var coreIndex = options.CoreIndex.Value;
226
227 if (coreIndex < 0 || coreIndex >= _logicalCoreCount)
228 {
229 throw new ArgumentOutOfRangeException(
230 nameof(options),
231 $"CPU core index {coreIndex} is out of range. Logical core count is {_logicalCoreCount}.");
232 }
233
234 _assignedCounts[coreIndex]++;
235 return DreamineThreadCoreAssignment.Dedicated(coreIndex, true);
236 }

다음을 참조함 : _assignedCounts, _logicalCoreCount, Dreamine.Threading.Models.DreamineThreadOptions.CoreIndex, Dreamine.Threading.Models.DreamineThreadCoreAssignment.Dedicated(), Dreamine.Threading.Models.DreamineThreadCoreAssignment.None().

다음에 의해서 참조됨 : Allocate().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ Release()

void Dreamine.Threading.Allocators.AutoCoreAllocator.Release ( DreamineThreadCoreAssignment assignment)
inline

전용 코어 할당의 사용 카운트를 감소시킵니다.

매개변수
assignment해제할 코어 할당입니다.
예외
ArgumentNullExceptionassignmentnull일 때 발생합니다.

Dreamine.Threading.Interfaces.IThreadCoreAllocator를 구현.

AutoCoreAllocator.cs 파일의 161 번째 라인에서 정의되었습니다.

162 {
163 ArgumentNullException.ThrowIfNull(assignment);
164
165 if (assignment.CoreIndex is null || assignment.IsOverflowPolling)
166 {
167 return;
168 }
169
170 lock (_syncRoot)
171 {
172 var coreIndex = assignment.CoreIndex.Value;
173
174 if (coreIndex < 0 || coreIndex >= _assignedCounts.Length)
175 {
176 return;
177 }
178
179 if (_assignedCounts[coreIndex] > 0)
180 {
181 _assignedCounts[coreIndex]--;
182 }
183 }
184 }

다음을 참조함 : _assignedCounts, _syncRoot, Dreamine.Threading.Models.DreamineThreadCoreAssignment.CoreIndex, Dreamine.Threading.Models.DreamineThreadCoreAssignment.IsOverflowPolling.

멤버 데이터 문서화

◆ _assignedCounts

readonly int [] Dreamine.Threading.Allocators.AutoCoreAllocator._assignedCounts
private

assigned Counts 값을 보관합니다.

AutoCoreAllocator.cs 파일의 42 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AllocateAuto(), AllocateManual(), AutoCoreAllocator(), Release().

◆ _logicalCoreCount

readonly int Dreamine.Threading.Allocators.AutoCoreAllocator._logicalCoreCount
private

logical Core Count 값을 보관합니다.

AutoCoreAllocator.cs 파일의 33 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : AllocateManual(), AutoCoreAllocator().

◆ _syncRoot

readonly object Dreamine.Threading.Allocators.AutoCoreAllocator._syncRoot = new()
private

sync Root 값을 보관합니다.

AutoCoreAllocator.cs 파일의 24 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : Allocate(), Release().


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: