synced with main repository

This commit is contained in:
Guenter Obiltschnig
2008-01-28 17:23:19 +00:00
parent fd1d5aed5f
commit da49971d0f
808 changed files with 1154 additions and 892 deletions

View File

@@ -1,7 +1,7 @@
//
// Mutex_WIN32.cpp
//
// $Id: //poco/Main/Foundation/src/Mutex_WIN32.cpp#13 $
// $Id: //poco/svn/Foundation/src/Mutex_WIN32.cpp#3 $
//
// Library: Foundation
// Package: Threading
@@ -35,6 +35,7 @@
#include "Poco/Mutex_WIN32.h"
#include "Poco/Timestamp.h"
namespace Poco {
@@ -54,4 +55,27 @@ MutexImpl::~MutexImpl()
}
bool MutexImpl::tryLockImpl(long milliseconds)
{
const int sleepMillis = 5;
Timestamp now;
Timestamp::TimeDiff diff(Timestamp::TimeDiff(milliseconds)*1000);
do
{
try
{
if (TryEnterCriticalSection(&_cs) == TRUE)
return true;
}
catch (...)
{
throw SystemException("cannot lock mutex");
}
Sleep(sleepMillis);
}
while (!now.isElapsed(diff));
return false;
}
} // namespace Poco