diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:49 +0300 |
commit | 718c552901d703c502ccbefdfc3c9028d608b947 (patch) | |
tree | 46534a98bbefcd7b1f3faa5b52c138ab27db75b7 /contrib/libs/poco/Foundation/src/Mutex_WIN32.cpp | |
parent | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (diff) | |
download | ydb-718c552901d703c502ccbefdfc3c9028d608b947.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/poco/Foundation/src/Mutex_WIN32.cpp')
-rw-r--r-- | contrib/libs/poco/Foundation/src/Mutex_WIN32.cpp | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/contrib/libs/poco/Foundation/src/Mutex_WIN32.cpp b/contrib/libs/poco/Foundation/src/Mutex_WIN32.cpp index 446f4affce..21c7f06a1a 100644 --- a/contrib/libs/poco/Foundation/src/Mutex_WIN32.cpp +++ b/contrib/libs/poco/Foundation/src/Mutex_WIN32.cpp @@ -1,59 +1,59 @@ -// -// Mutex_WIN32.cpp -// -// Library: Foundation -// Package: Threading -// Module: Mutex -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Mutex_WIN32.h" -#include "Poco/Timestamp.h" - - -namespace Poco { - - -MutexImpl::MutexImpl() -{ - // the fct has a boolean return value under WInnNt/2000/XP but not on Win98 - // the return only checks if the input address of &_cs was valid, so it is safe to omit it - InitializeCriticalSectionAndSpinCount(&_cs, 4000); -} - - -MutexImpl::~MutexImpl() -{ - DeleteCriticalSection(&_cs); -} - - -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 +// +// Mutex_WIN32.cpp +// +// Library: Foundation +// Package: Threading +// Module: Mutex +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/Mutex_WIN32.h" +#include "Poco/Timestamp.h" + + +namespace Poco { + + +MutexImpl::MutexImpl() +{ + // the fct has a boolean return value under WInnNt/2000/XP but not on Win98 + // the return only checks if the input address of &_cs was valid, so it is safe to omit it + InitializeCriticalSectionAndSpinCount(&_cs, 4000); +} + + +MutexImpl::~MutexImpl() +{ + DeleteCriticalSection(&_cs); +} + + +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 |