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/Net/src/SocketNotifier.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/Net/src/SocketNotifier.cpp')
-rw-r--r-- | contrib/libs/poco/Net/src/SocketNotifier.cpp | 178 |
1 files changed, 89 insertions, 89 deletions
diff --git a/contrib/libs/poco/Net/src/SocketNotifier.cpp b/contrib/libs/poco/Net/src/SocketNotifier.cpp index 9bbf6ca826..8c9bcebe28 100644 --- a/contrib/libs/poco/Net/src/SocketNotifier.cpp +++ b/contrib/libs/poco/Net/src/SocketNotifier.cpp @@ -1,89 +1,89 @@ -// -// SocketNotifier.cpp -// -// Library: Net -// Package: Reactor -// Module: SocketNotifier -// -// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Net/SocketNotifier.h" -#include "Poco/Net/SocketReactor.h" -#include "Poco/Net/SocketNotification.h" - - -namespace Poco { -namespace Net { - - -SocketNotifier::SocketNotifier(const Socket& socket): - _socket(socket) -{ -} - - -SocketNotifier::~SocketNotifier() -{ -} - - -void SocketNotifier::addObserver(SocketReactor* pReactor, const Poco::AbstractObserver& observer) -{ - _nc.addObserver(observer); - if (observer.accepts(pReactor->_pReadableNotification)) - _events.insert(pReactor->_pReadableNotification.get()); - else if (observer.accepts(pReactor->_pWritableNotification)) - _events.insert(pReactor->_pWritableNotification.get()); - else if (observer.accepts(pReactor->_pErrorNotification)) - _events.insert(pReactor->_pErrorNotification.get()); - else if (observer.accepts(pReactor->_pTimeoutNotification)) - _events.insert(pReactor->_pTimeoutNotification.get()); -} - - -void SocketNotifier::removeObserver(SocketReactor* pReactor, const Poco::AbstractObserver& observer) -{ - _nc.removeObserver(observer); - EventSet::iterator it = _events.end(); - if (observer.accepts(pReactor->_pReadableNotification)) - it = _events.find(pReactor->_pReadableNotification.get()); - else if (observer.accepts(pReactor->_pWritableNotification)) - it = _events.find(pReactor->_pWritableNotification.get()); - else if (observer.accepts(pReactor->_pErrorNotification)) - it = _events.find(pReactor->_pErrorNotification.get()); - else if (observer.accepts(pReactor->_pTimeoutNotification)) - it = _events.find(pReactor->_pTimeoutNotification.get()); - if (it != _events.end()) - _events.erase(it); -} - - -namespace -{ - static Socket nullSocket; -} - - -void SocketNotifier::dispatch(SocketNotification* pNotification) -{ - pNotification->setSocket(_socket); - pNotification->duplicate(); - try - { - _nc.postNotification(pNotification); - } - catch (...) - { - pNotification->setSocket(nullSocket); - throw; - } - pNotification->setSocket(nullSocket); -} - - -} } // namespace Poco::Net +// +// SocketNotifier.cpp +// +// Library: Net +// Package: Reactor +// Module: SocketNotifier +// +// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/Net/SocketNotifier.h" +#include "Poco/Net/SocketReactor.h" +#include "Poco/Net/SocketNotification.h" + + +namespace Poco { +namespace Net { + + +SocketNotifier::SocketNotifier(const Socket& socket): + _socket(socket) +{ +} + + +SocketNotifier::~SocketNotifier() +{ +} + + +void SocketNotifier::addObserver(SocketReactor* pReactor, const Poco::AbstractObserver& observer) +{ + _nc.addObserver(observer); + if (observer.accepts(pReactor->_pReadableNotification)) + _events.insert(pReactor->_pReadableNotification.get()); + else if (observer.accepts(pReactor->_pWritableNotification)) + _events.insert(pReactor->_pWritableNotification.get()); + else if (observer.accepts(pReactor->_pErrorNotification)) + _events.insert(pReactor->_pErrorNotification.get()); + else if (observer.accepts(pReactor->_pTimeoutNotification)) + _events.insert(pReactor->_pTimeoutNotification.get()); +} + + +void SocketNotifier::removeObserver(SocketReactor* pReactor, const Poco::AbstractObserver& observer) +{ + _nc.removeObserver(observer); + EventSet::iterator it = _events.end(); + if (observer.accepts(pReactor->_pReadableNotification)) + it = _events.find(pReactor->_pReadableNotification.get()); + else if (observer.accepts(pReactor->_pWritableNotification)) + it = _events.find(pReactor->_pWritableNotification.get()); + else if (observer.accepts(pReactor->_pErrorNotification)) + it = _events.find(pReactor->_pErrorNotification.get()); + else if (observer.accepts(pReactor->_pTimeoutNotification)) + it = _events.find(pReactor->_pTimeoutNotification.get()); + if (it != _events.end()) + _events.erase(it); +} + + +namespace +{ + static Socket nullSocket; +} + + +void SocketNotifier::dispatch(SocketNotification* pNotification) +{ + pNotification->setSocket(_socket); + pNotification->duplicate(); + try + { + _nc.postNotification(pNotification); + } + catch (...) + { + pNotification->setSocket(nullSocket); + throw; + } + pNotification->setSocket(nullSocket); +} + + +} } // namespace Poco::Net |