diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/poco/Foundation/include/Poco/Event_POSIX.h | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/poco/Foundation/include/Poco/Event_POSIX.h')
-rw-r--r-- | contrib/libs/poco/Foundation/include/Poco/Event_POSIX.h | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/contrib/libs/poco/Foundation/include/Poco/Event_POSIX.h b/contrib/libs/poco/Foundation/include/Poco/Event_POSIX.h index 21231ab3ce..b7eb83aa6e 100644 --- a/contrib/libs/poco/Foundation/include/Poco/Event_POSIX.h +++ b/contrib/libs/poco/Foundation/include/Poco/Event_POSIX.h @@ -1,77 +1,77 @@ -// -// Event_POSIX.h -// -// Library: Foundation -// Package: Threading -// Module: Event -// -// Definition of the EventImpl class for POSIX Threads. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_Event_POSIX_INCLUDED -#define Foundation_Event_POSIX_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/Exception.h" -#include <pthread.h> -#include <errno.h> - - -namespace Poco { - - -class Foundation_API EventImpl -{ -protected: - EventImpl(bool autoReset); - ~EventImpl(); - void setImpl(); - void waitImpl(); - bool waitImpl(long milliseconds); - void resetImpl(); - -private: - bool _auto; - volatile bool _state; - pthread_mutex_t _mutex; - pthread_cond_t _cond; -}; - - -// -// inlines -// -inline void EventImpl::setImpl() -{ - if (pthread_mutex_lock(&_mutex)) - throw SystemException("cannot signal event (lock)"); - _state = true; - if (pthread_cond_broadcast(&_cond)) - { - pthread_mutex_unlock(&_mutex); - throw SystemException("cannot signal event"); - } - pthread_mutex_unlock(&_mutex); -} - - -inline void EventImpl::resetImpl() -{ - if (pthread_mutex_lock(&_mutex)) - throw SystemException("cannot reset event"); - _state = false; - pthread_mutex_unlock(&_mutex); -} - - -} // namespace Poco - - -#endif // Foundation_Event_POSIX_INCLUDED +// +// Event_POSIX.h +// +// Library: Foundation +// Package: Threading +// Module: Event +// +// Definition of the EventImpl class for POSIX Threads. +// +// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#ifndef Foundation_Event_POSIX_INCLUDED +#define Foundation_Event_POSIX_INCLUDED + + +#include "Poco/Foundation.h" +#include "Poco/Exception.h" +#include <pthread.h> +#include <errno.h> + + +namespace Poco { + + +class Foundation_API EventImpl +{ +protected: + EventImpl(bool autoReset); + ~EventImpl(); + void setImpl(); + void waitImpl(); + bool waitImpl(long milliseconds); + void resetImpl(); + +private: + bool _auto; + volatile bool _state; + pthread_mutex_t _mutex; + pthread_cond_t _cond; +}; + + +// +// inlines +// +inline void EventImpl::setImpl() +{ + if (pthread_mutex_lock(&_mutex)) + throw SystemException("cannot signal event (lock)"); + _state = true; + if (pthread_cond_broadcast(&_cond)) + { + pthread_mutex_unlock(&_mutex); + throw SystemException("cannot signal event"); + } + pthread_mutex_unlock(&_mutex); +} + + +inline void EventImpl::resetImpl() +{ + if (pthread_mutex_lock(&_mutex)) + throw SystemException("cannot reset event"); + _state = false; + pthread_mutex_unlock(&_mutex); +} + + +} // namespace Poco + + +#endif // Foundation_Event_POSIX_INCLUDED |