diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2003-06-10 05:00:45 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2003-06-10 05:00:45 +0000 |
commit | 2660779a26b8ba285b0ab172c8f48d50dd1da918 (patch) | |
tree | 8ea8f972be66af828051026a138282769e980adb /wait.cpp | |
parent | 79714ed200a1687f3ed63bc8ff6723a5f99b59f0 (diff) | |
download | cryptopp-2660779a26b8ba285b0ab172c8f48d50dd1da918.tar.gz |
detect no-wait loop in debug build
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@79 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'wait.cpp')
-rw-r--r-- | wait.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -25,6 +25,7 @@ unsigned int WaitObjectContainer::MaxWaitObjects() } WaitObjectContainer::WaitObjectContainer() + : m_sameResultCount(0), m_timer(Timer::MILLISECONDS) { Clear(); } @@ -86,6 +87,14 @@ WaitObjectContainer::~WaitObjectContainer() void WaitObjectContainer::AddHandle(HANDLE handle) { +#ifndef NDEBUG + if (m_handles.size() == m_lastResult && m_timer.ElapsedTime() > 1000) + { + if (m_sameResultCount > m_timer.ElapsedTime()) + try {throw 0;} catch (...) {} // possible no-wait loop, break in debugger + m_timer.StartTimer(); + } +#endif m_handles.push_back(handle); } @@ -201,7 +210,18 @@ bool WaitObjectContainer::Wait(unsigned long milliseconds) { DWORD result = ::WaitForMultipleObjects(m_handles.size(), &m_handles[0], FALSE, milliseconds); if (result >= WAIT_OBJECT_0 && result < WAIT_OBJECT_0 + m_handles.size()) + { +#ifndef NDEBUG + if (result == m_lastResult) + m_sameResultCount++; + else + { + m_lastResult = result; + m_sameResultCount = 0; + } +#endif return true; + } else if (result == WAIT_TIMEOUT) return false; else |