Global (Windows): prefers NtClose over CloseHandle

This commit is contained in:
李通洲
2026-03-13 10:58:38 +08:00
parent ea6ad4ac86
commit ca9c67353f
5 changed files with 11 additions and 11 deletions
+4 -4
View File
@@ -4,7 +4,7 @@
#ifdef FF_HAVE_THREADS
#if defined(_WIN32)
#include <handleapi.h>
#include <winternl.h>
#include <synchapi.h>
#include <process.h>
#include <processthreadsapi.h>
@@ -18,16 +18,16 @@
}
#define FF_THREAD_ENTRY_DECL_WRAPPER(fn, paramType) static __stdcall unsigned fn ## ThreadMain (void* data) { fn((paramType)data); return 0; }
#define FF_THREAD_ENTRY_DECL_WRAPPER_NOPARAM(fn) static __stdcall unsigned fn ## ThreadMain () { fn(); return 0; }
static inline void ffThreadDetach(FFThreadType thread) { CloseHandle(thread); }
static inline void ffThreadDetach(FFThreadType thread) { NtClose(thread); }
static inline bool ffThreadJoin(FFThreadType thread, uint32_t timeout)
{
if (WaitForSingleObject(thread, timeout == 0 ? (DWORD) -1 : timeout) != 0 /*WAIT_OBJECT_0*/)
{
TerminateThread(thread, (DWORD) -1);
CloseHandle(thread);
NtClose(thread);
return false;
}
CloseHandle(thread);
NtClose(thread);
return true;
}
#else