diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/poco/Foundation/src/Mutex_WINCE.cpp | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/poco/Foundation/src/Mutex_WINCE.cpp')
-rw-r--r-- | contrib/libs/poco/Foundation/src/Mutex_WINCE.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/contrib/libs/poco/Foundation/src/Mutex_WINCE.cpp b/contrib/libs/poco/Foundation/src/Mutex_WINCE.cpp new file mode 100644 index 0000000000..90ea6956d8 --- /dev/null +++ b/contrib/libs/poco/Foundation/src/Mutex_WINCE.cpp @@ -0,0 +1,80 @@ +// +// Mutex_WINCE.cpp +// +// Library: Foundation +// Package: Threading +// Module: Mutex +// +// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/Mutex_WINCE.h" + + +namespace Poco { + + +MutexImpl::MutexImpl() +{ + _mutex = CreateMutexW(NULL, FALSE, NULL); + if (!_mutex) throw SystemException("cannot create mutex"); +} + + +MutexImpl::~MutexImpl() +{ + CloseHandle(_mutex); +} + + +void MutexImpl::lockImpl() +{ + switch (WaitForSingleObject(_mutex, INFINITE)) + { + case WAIT_OBJECT_0: + return; + default: + throw SystemException("cannot lock mutex"); + } +} + + +bool MutexImpl::tryLockImpl() +{ + switch (WaitForSingleObject(_mutex, 0)) + { + case WAIT_TIMEOUT: + return false; + case WAIT_OBJECT_0: + return true; + default: + throw SystemException("cannot lock mutex"); + } +} + + +bool MutexImpl::tryLockImpl(long milliseconds) +{ + switch (WaitForSingleObject(_mutex, milliseconds + 1)) + { + case WAIT_TIMEOUT: + return false; + case WAIT_OBJECT_0: + return true; + default: + throw SystemException("cannot lock mutex"); + } +} + + +void MutexImpl::unlockImpl() +{ + ReleaseMutex(_mutex); +} + + +} // namespace Poco |