From 2bbbde1e2b7bdad8328207f422f4c5bbed10f4e1 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Sat, 11 Dec 2004 09:41:13 +0000 Subject: [PATCH] thread wrappers --- BasiliskII/src/Windows/util_windows.cpp | 22 ++++++++++++++++++++++ BasiliskII/src/Windows/util_windows.h | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/BasiliskII/src/Windows/util_windows.cpp b/BasiliskII/src/Windows/util_windows.cpp index 20b4a0e6..e7f574fa 100755 --- a/BasiliskII/src/Windows/util_windows.cpp +++ b/BasiliskII/src/Windows/util_windows.cpp @@ -83,3 +83,25 @@ int32 get_file_size( const char *path ) } return(size); } + + +/* + * Thread wrappers + */ + +HANDLE create_thread(LPTHREAD_START_ROUTINE start_routine, void *arg) +{ + DWORD dwThreadId; + return CreateThread(NULL, 0, start_routine, arg, 0, &dwThreadId); +} + +void wait_thread(HANDLE thread) +{ + WaitForSingleObject(thread, INFINITE); + CloseHandle(thread); +} + +void kill_thread(HANDLE thread) +{ + TerminateThread(thread, 0); +} diff --git a/BasiliskII/src/Windows/util_windows.h b/BasiliskII/src/Windows/util_windows.h index 5411ccf0..5c2892f0 100755 --- a/BasiliskII/src/Windows/util_windows.h +++ b/BasiliskII/src/Windows/util_windows.h @@ -27,4 +27,8 @@ BOOL exists( const char *path ); int32 get_file_size( const char *path ); BOOL create_file( const char *path, DWORD size ); +extern HANDLE create_thread(LPTHREAD_START_ROUTINE start_routine, void *arg = NULL); +extern void wait_thread(HANDLE thread); +extern void kill_thread(HANDLE thread); + #endif // _UTIL_WINDOWS_H