Changeset 3505 in kBuild
- Timestamp:
- Dec 15, 2021 10:53:57 PM (3 years ago)
- Location:
- trunk/src/kash
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/shfile.c
r3477 r3505 221 221 { 222 222 KBOOL decrement_pending = K_FALSE; 223 shthread_set_name("Async CloseHandle"); 223 224 while (!g_shfile_async_close.terminate_threads) 224 225 { -
trunk/src/kash/shthread.c
r3477 r3505 108 108 } 109 109 110 111 /** 112 * Sets the name of the current thread if supported by the OS. 113 */ 114 void shthread_set_name(const char *name) 115 { 116 #if K_OS == K_OS_WINDOWS 117 typedef BOOL (WINAPI * PFNSETTHREADDESCRIPTION)(HANDLE, WCHAR *); 118 static KBOOL volatile s_initialized = K_FALSE; 119 static PFNSETTHREADDESCRIPTION volatile s_pfnSetThreadDescription = NULL; 120 PFNSETTHREADDESCRIPTION pfnSetThreadDescription = s_pfnSetThreadDescription; 121 WCHAR wszName[32]; 122 size_t i; 123 124 /* Get the function pointer, return if not available. */ 125 if (pfnSetThreadDescription) 126 { } 127 else if (s_initialized) 128 return; 129 else 130 { 131 pfnSetThreadDescription = (PFNSETTHREADDESCRIPTION)GetProcAddress(GetModuleHandleW(L"KERNEL32.DLL"), 132 "SetThreadDescription"); 133 s_pfnSetThreadDescription = pfnSetThreadDescription; 134 s_initialized = K_TRUE; 135 if (!pfnSetThreadDescription) 136 return; 137 } 138 139 /* Convert the name to UTF-16 and call the API. */ 140 i = strlen(name); 141 kHlpAssertStmt(i < K_ELEMENTS(wszName), i = K_ELEMENTS(wszName)); 142 wszName[i] = '\0'; 143 while (i-- > 0) 144 wszName[i] = name[i]; 145 146 pfnSetThreadDescription(GetCurrentThread(), wszName); 147 #else 148 K_NOREF(name); 149 #endif 150 } 151
Note:
See TracChangeset
for help on using the changeset viewer.