summaryrefslogtreecommitdiff
path: root/wait.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-03-21 07:50:30 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2003-03-21 07:50:30 +0000
commitc0b69c9d19bd817a4f6e4cd58338ad06107a745e (patch)
tree135f84be01bdbe750df17a81cb6d7ef9fa1e529e /wait.cpp
parentbab6ce107cd7a47caaad689466dc1dbe94f1940b (diff)
downloadcryptopp-c0b69c9d19bd817a4f6e4cd58338ad06107a745e.tar.gz
minor changes
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@46 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'wait.cpp')
-rw-r--r--wait.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/wait.cpp b/wait.cpp
index 99a2ad4..05d485b 100644
--- a/wait.cpp
+++ b/wait.cpp
@@ -47,27 +47,34 @@ struct WaitingThreadData
WaitObjectContainer::~WaitObjectContainer()
{
- if (!m_threads.empty())
+ try // don't let exceptions escape destructor
{
- HANDLE threadHandles[MAXIMUM_WAIT_OBJECTS];
- unsigned int i;
- for (i=0; i<m_threads.size(); i++)
+ if (!m_threads.empty())
{
- WaitingThreadData &thread = *m_threads[i];
- while (!thread.waitingToWait) // spin until thread is in the initial "waiting to wait" state
- Sleep(0);
- thread.terminate = true;
- threadHandles[i] = thread.threadHandle;
+ HANDLE threadHandles[MAXIMUM_WAIT_OBJECTS];
+ unsigned int i;
+ for (i=0; i<m_threads.size(); i++)
+ {
+ WaitingThreadData &thread = *m_threads[i];
+ while (!thread.waitingToWait) // spin until thread is in the initial "waiting to wait" state
+ Sleep(0);
+ thread.terminate = true;
+ threadHandles[i] = thread.threadHandle;
+ }
+ PulseEvent(m_startWaiting);
+ ::WaitForMultipleObjects(m_threads.size(), threadHandles, TRUE, INFINITE);
+ for (i=0; i<m_threads.size(); i++)
+ CloseHandle(threadHandles[i]);
+ CloseHandle(m_startWaiting);
+ CloseHandle(m_stopWaiting);
}
- PulseEvent(m_startWaiting);
- ::WaitForMultipleObjects(m_threads.size(), threadHandles, TRUE, INFINITE);
- for (i=0; i<m_threads.size(); i++)
- CloseHandle(threadHandles[i]);
- CloseHandle(m_startWaiting);
- CloseHandle(m_stopWaiting);
+ }
+ catch (...)
+ {
}
}
+
void WaitObjectContainer::AddHandle(HANDLE handle)
{
m_handles.push_back(handle);
@@ -86,7 +93,7 @@ DWORD WINAPI WaitingThread(LPVOID lParam)
thread.waitingToWait = false;
if (thread.terminate)
- return S_OK;
+ break;
if (!thread.count)
continue;
@@ -105,6 +112,8 @@ DWORD WINAPI WaitingThread(LPVOID lParam)
*thread.error = ::GetLastError();
}
}
+
+ return S_OK; // return a value here to avoid compiler warning
}
void WaitObjectContainer::CreateThreads(unsigned int count)