Dreamine.Threading.Windows 1.0.1
이 패키지는 다른 어셈블리에서 `DMContainer`를 partial class로 확장하지 않습니다. 등록은 별도의 Registration 클래스를 통해 제공합니다.
로딩중...
검색중...
일치하는것 없음
Dreamine.Threading.Windows.Services.WindowsThreadAffinityService 클래스 참조sealed

더 자세히 ...

Dreamine.Threading.Windows.Services.WindowsThreadAffinityService에 대한 상속 다이어그램 :
Dreamine.Threading.Windows.Services.WindowsThreadAffinityService에 대한 협력 다이어그램:

Public 멤버 함수

void ApplyToCurrentThread (int coreIndex)
void ClearCurrentThreadAffinity ()

상세한 설명

현재 Windows 스레드에 CPU 선호도를 적용합니다.

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

멤버 함수 문서화

◆ ApplyToCurrentThread()

void Dreamine.Threading.Windows.Services.WindowsThreadAffinityService.ApplyToCurrentThread ( int coreIndex)
inline

현재 Windows 스레드의 선호도 마스크를 지정한 단일 CPU 코어로 설정합니다.

매개변수
coreIndex현재 프로세스 비트 폭 안의 0부터 시작하는 CPU 코어 인덱스입니다.
예외
ArgumentOutOfRangeExceptioncoreIndex 가 음수이거나 선호도 마스크 비트 폭을 벗어날 때 발생합니다.
Win32ExceptionWindows가 스레드 선호도 마스크 설정을 거부할 때 발생합니다.
DllNotFoundExceptionWindows 네이티브 라이브러리를 로드할 수 없을 때 발생할 수 있습니다.

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

58 {
59 if (coreIndex < 0)
60 {
61 throw new ArgumentOutOfRangeException(nameof(coreIndex), "CPU core index cannot be negative.");
62 }
63
64 if (coreIndex >= IntPtr.Size * 8)
65 {
66 throw new ArgumentOutOfRangeException(
67 nameof(coreIndex),
68 $"CPU core index {coreIndex} exceeds the affinity mask width.");
69 }
70
71 var mask = new UIntPtr(1UL << coreIndex);
72 var currentThread = Kernel32NativeMethods.GetCurrentThread();
73
74 var previousMask = Kernel32NativeMethods.SetThreadAffinityMask(currentThread, mask);
75
76 if (previousMask == UIntPtr.Zero)
77 {
78 throw new Win32Exception(
79 System.Runtime.InteropServices.Marshal.GetLastWin32Error(),
80 $"Failed to set thread affinity. CoreIndex={coreIndex}");
81 }
82 }

◆ ClearCurrentThreadAffinity()

void Dreamine.Threading.Windows.Services.WindowsThreadAffinityService.ClearCurrentThreadAffinity ( )
inline

현재 스레드의 CPU 선호도를 해제합니다. 현재 구현은 이전 마스크를 보존하지 않아 아무 작업도 하지 않습니다.

실제 복원에는 ApplyToCurrentThread 호출 전에 이전 마스크를 스레드별로 보존하는 계약 확장이 필요합니다.

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

101 {
102 /*
103 * Windows SetThreadAffinityMask requires a valid mask.
104 * Restoring the original process-wide scheduling behavior requires the previous
105 * affinity mask to be stored per thread.
106 *
107 * The current Core interface does not expose a restore token, so this method is
108 * intentionally a no-op for now.
109 *
110 * Future improvement:
111 * - Change IThreadAffinityService.ApplyToCurrentThread to return a restore handle.
112 * - Restore the previous affinity mask in Clear/Dispose.
113 */
114 }

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