From 9afbc31daffd4b7996498dc610b81af2c0321c00 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 7 Aug 2007 09:32:16 +0000 Subject: [PATCH] stopped thread handles from on win32 --- .../juce_win32_Threads.cpp | 18 ++++++++++++++++-- src/juce_core/threads/juce_Thread.cpp | 7 +++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/build/win32/platform_specific_code/juce_win32_Threads.cpp b/build/win32/platform_specific_code/juce_win32_Threads.cpp index 348f4a88cc..48803d65a7 100644 --- a/build/win32/platform_specific_code/juce_win32_Threads.cpp +++ b/build/win32/platform_specific_code/juce_win32_Threads.cpp @@ -91,7 +91,11 @@ void CriticalSection::exit() const throw() //============================================================================== WaitableEvent::WaitableEvent() throw() +#ifdef JUCE_DEBUG + : internal (CreateEvent (0, FALSE, FALSE, _T("Juce WaitableEvent"))) +#else : internal (CreateEvent (0, FALSE, FALSE, 0)) +#endif { } @@ -125,10 +129,15 @@ static unsigned int __stdcall threadEntryProc (void* userData) throw() juce_threadEntryPoint (userData); - _endthread(); + _endthreadex(0); return 0; } +void juce_CloseThreadHandle (void* handle) throw() +{ + CloseHandle ((HANDLE) handle); +} + void* juce_createThread (void* userData) throw() { unsigned int threadId; @@ -217,7 +226,12 @@ static HANDLE sleepEvent = 0; void juce_initialiseThreadEvents() throw() { - sleepEvent = CreateEvent (0, 0, 0, 0); + if (sleepEvent == 0) +#ifdef JUCE_DEBUG + sleepEvent = CreateEvent (0, 0, 0, _T("Juce Sleep Event")); +#else + sleepEvent = CreateEvent (0, 0, 0, 0); +#endif } void Thread::yield() throw() diff --git a/src/juce_core/threads/juce_Thread.cpp b/src/juce_core/threads/juce_Thread.cpp index 13823317b6..bf2d500aed 100644 --- a/src/juce_core/threads/juce_Thread.cpp +++ b/src/juce_core/threads/juce_Thread.cpp @@ -44,6 +44,9 @@ void* juce_createThread (void* userData) throw(); void juce_killThread (void* handle) throw(); void juce_setThreadPriority (void* handle, int priority) throw(); void juce_setCurrentThreadName (const String& name) throw(); +#if JUCE_WIN32 +void juce_CloseThreadHandle (void* handle) throw(); +#endif //============================================================================== static VoidArray runningThreads (4); @@ -78,6 +81,10 @@ void Thread::threadEntryPoint (Thread* const thread) throw() runningThreads.removeValue (thread); runningThreadsLock.exit(); +#if JUCE_WIN32 + juce_CloseThreadHandle (thread->threadHandle_); +#endif + thread->threadHandle_ = 0; thread->threadId_ = 0; }