aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp
diff options
context:
space:
mode:
authororivej <orivej@yandex-team.ru>2022-02-10 16:45:01 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:01 +0300
commit2d37894b1b037cf24231090eda8589bbb44fb6fc (patch)
treebe835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp
parent718c552901d703c502ccbefdfc3c9028d608b947 (diff)
downloadydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp')
-rw-r--r--contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp232
1 files changed, 116 insertions, 116 deletions
diff --git a/contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp b/contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp
index fc20a04fe8..a50bd2fcf4 100644
--- a/contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp
+++ b/contrib/libs/poco/Foundation/src/ActiveDispatcher.cpp
@@ -1,116 +1,116 @@
-//
-// ActiveDispatcher.cpp
-//
-// Library: Foundation
-// Package: Threading
-// Module: ActiveObjects
-//
-// Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH.
-// and Contributors.
-//
-// SPDX-License-Identifier: BSL-1.0
-//
-
-
-#include "Poco/ActiveDispatcher.h"
-#include "Poco/Notification.h"
-#include "Poco/AutoPtr.h"
-
-
-namespace Poco {
-
-
-namespace
-{
- class MethodNotification: public Notification
- {
- public:
- MethodNotification(ActiveRunnableBase::Ptr pRunnable):
- _pRunnable(pRunnable)
- {
- }
-
- ActiveRunnableBase::Ptr runnable() const
- {
- return _pRunnable;
- }
-
- private:
- ActiveRunnableBase::Ptr _pRunnable;
- };
-
- class StopNotification: public Notification
- {
- };
-}
-
-
-ActiveDispatcher::ActiveDispatcher()
-{
-}
-
-
-ActiveDispatcher::ActiveDispatcher(Thread::Priority prio)
-{
- _thread.setPriority(prio);
-}
-
-
-ActiveDispatcher::~ActiveDispatcher()
-{
- try
- {
- stop();
- }
- catch (...)
- {
- }
-}
-
-
-void ActiveDispatcher::start(ActiveRunnableBase::Ptr pRunnable)
-{
- poco_check_ptr (pRunnable);
-
- if (!_thread.isRunning())
- {
- _thread.start(*this);
- }
-
- _queue.enqueueNotification(new MethodNotification(pRunnable));
-}
-
-
-void ActiveDispatcher::cancel()
-{
- _queue.clear();
-}
-
-
-void ActiveDispatcher::run()
-{
- AutoPtr<Notification> pNf = _queue.waitDequeueNotification();
- while (pNf && !dynamic_cast<StopNotification*>(pNf.get()))
- {
- MethodNotification* pMethodNf = dynamic_cast<MethodNotification*>(pNf.get());
- poco_check_ptr (pMethodNf);
- ActiveRunnableBase::Ptr pRunnable = pMethodNf->runnable();
- pRunnable->duplicate(); // run will release
- pRunnable->run();
- pRunnable = 0;
- pNf = 0;
- pNf = _queue.waitDequeueNotification();
- }
-}
-
-
-void ActiveDispatcher::stop()
-{
- _queue.clear();
- _queue.wakeUpAll();
- _queue.enqueueNotification(new StopNotification);
- _thread.join();
-}
-
-
-} // namespace Poco
+//
+// ActiveDispatcher.cpp
+//
+// Library: Foundation
+// Package: Threading
+// Module: ActiveObjects
+//
+// Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH.
+// and Contributors.
+//
+// SPDX-License-Identifier: BSL-1.0
+//
+
+
+#include "Poco/ActiveDispatcher.h"
+#include "Poco/Notification.h"
+#include "Poco/AutoPtr.h"
+
+
+namespace Poco {
+
+
+namespace
+{
+ class MethodNotification: public Notification
+ {
+ public:
+ MethodNotification(ActiveRunnableBase::Ptr pRunnable):
+ _pRunnable(pRunnable)
+ {
+ }
+
+ ActiveRunnableBase::Ptr runnable() const
+ {
+ return _pRunnable;
+ }
+
+ private:
+ ActiveRunnableBase::Ptr _pRunnable;
+ };
+
+ class StopNotification: public Notification
+ {
+ };
+}
+
+
+ActiveDispatcher::ActiveDispatcher()
+{
+}
+
+
+ActiveDispatcher::ActiveDispatcher(Thread::Priority prio)
+{
+ _thread.setPriority(prio);
+}
+
+
+ActiveDispatcher::~ActiveDispatcher()
+{
+ try
+ {
+ stop();
+ }
+ catch (...)
+ {
+ }
+}
+
+
+void ActiveDispatcher::start(ActiveRunnableBase::Ptr pRunnable)
+{
+ poco_check_ptr (pRunnable);
+
+ if (!_thread.isRunning())
+ {
+ _thread.start(*this);
+ }
+
+ _queue.enqueueNotification(new MethodNotification(pRunnable));
+}
+
+
+void ActiveDispatcher::cancel()
+{
+ _queue.clear();
+}
+
+
+void ActiveDispatcher::run()
+{
+ AutoPtr<Notification> pNf = _queue.waitDequeueNotification();
+ while (pNf && !dynamic_cast<StopNotification*>(pNf.get()))
+ {
+ MethodNotification* pMethodNf = dynamic_cast<MethodNotification*>(pNf.get());
+ poco_check_ptr (pMethodNf);
+ ActiveRunnableBase::Ptr pRunnable = pMethodNf->runnable();
+ pRunnable->duplicate(); // run will release
+ pRunnable->run();
+ pRunnable = 0;
+ pNf = 0;
+ pNf = _queue.waitDequeueNotification();
+ }
+}
+
+
+void ActiveDispatcher::stop()
+{
+ _queue.clear();
+ _queue.wakeUpAll();
+ _queue.enqueueNotification(new StopNotification);
+ _thread.join();
+}
+
+
+} // namespace Poco