-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(AsyncObserver): Improve NotificationCenter speed and usability #4414 * fix(Notification): add missing header * feat(Any): add checkers for holding nullptr #4447 * feat(NotificationCenter): g++ build and refactoring #4414 * fix(Observer): compile errors on some compilers #4414 * fix(NotificationCenter): compile errors #4414 * chore(ParallelSocketAcceptor): remove unnecessary include and using from header * feat(AsyncNotificationCenter): add #4414 * test(AsyncNotificationCenter): add mixed observer types to the test #4414 * fix(AsyncNotificationCenter): hangs on program exit #4414 * fix(dev): friend not honored, temporarily make private members public * fix(AsyncNotificationCenter); remove default #4414
- Loading branch information
Showing
24 changed files
with
882 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// AsyncNotificationCenter.h | ||
// | ||
// Library: Foundation | ||
// Package: Notifications | ||
// Module: AsyncNotificationCenter | ||
// | ||
// Definition of the AsyncNotificationCenter class. | ||
// | ||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. | ||
// Aleph ONE Software Engineering d.o.o., | ||
// and Contributors. | ||
// | ||
// SPDX-License-Identifier: BSL-1.0 | ||
// | ||
|
||
|
||
#ifndef Foundation_AsyncNotificationCenter_INCLUDED | ||
#define Foundation_AsyncNotificationCenter_INCLUDED | ||
|
||
|
||
#include "Poco/Foundation.h" | ||
#include "Poco/NotificationCenter.h" | ||
#include "Poco/Thread.h" | ||
#include "Poco/Stopwatch.h" | ||
#include "Poco/Debugger.h" | ||
#include "Poco/ErrorHandler.h" | ||
#include "Poco/Format.h" | ||
#include "Poco/RunnableAdapter.h" | ||
#include "Poco/NotificationQueue.h" | ||
|
||
|
||
namespace Poco { | ||
|
||
|
||
class Foundation_API AsyncNotificationCenter: public NotificationCenter | ||
/// AsyncNotificationCenter decouples posting of notifications | ||
/// from notifying subscribers by calling observers' notification | ||
/// handler in a dedicated thread. | ||
{ | ||
public: | ||
AsyncNotificationCenter(); | ||
/// Creates the AsyncNotificationCenter and starts the notifying thread. | ||
|
||
~AsyncNotificationCenter(); | ||
/// Stops the notifying thread and destroys the AsyncNotificationCenter. | ||
|
||
AsyncNotificationCenter& operator = (const AsyncNotificationCenter&) = delete; | ||
AsyncNotificationCenter(const AsyncNotificationCenter&) = delete; | ||
AsyncNotificationCenter& operator = (AsyncNotificationCenter&&) = delete; | ||
AsyncNotificationCenter(AsyncNotificationCenter&&) = delete; | ||
|
||
virtual void postNotification(Notification::Ptr pNotification); | ||
/// Enqueues notification into the notification queue. | ||
|
||
virtual int backlog() const; | ||
/// Returns the numbner of notifications in the notification queue. | ||
|
||
private: | ||
void start(); | ||
void stop(); | ||
void dequeue(); | ||
|
||
using Adapter = RunnableAdapter<AsyncNotificationCenter>; | ||
|
||
Thread _thread; | ||
NotificationQueue _nq; | ||
Adapter _ra; | ||
std::atomic<bool> _started; | ||
std::atomic<bool> _done; | ||
}; | ||
|
||
|
||
} // namespace Poco | ||
|
||
|
||
#endif // Foundation_AsyncNotificationCenter_INCLUDED |
Oops, something went wrong.