AsyncObserver (#4444)

* 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
This commit is contained in:
Aleksandar Fabijanic
2024-02-16 09:34:19 +01:00
committed by GitHub
parent 30a0a06bac
commit 88be66972a
24 changed files with 882 additions and 139 deletions

View File

@@ -74,15 +74,10 @@ public:
void notify(Notification* pNf) const
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_pObject)
{
N* pCastNf = dynamic_cast<N*>(pNf);
if (pCastNf)
{
pCastNf->duplicate();
(_pObject->*_method)(pCastNf);
}
pNf->duplicate();
(_pObject->*_method)(static_cast<N*>(pNf));
}
}
@@ -92,9 +87,15 @@ public:
return pObs && pObs->_pObject == _pObject && pObs->_method == _method;
}
bool accepts(Notification* pNf, const char* pName = 0) const
[[deprecated("use `bool accepts(const Notification::Ptr&)` instead")]]
bool accepts(Notification* pNf, const char* pName) const
{
return dynamic_cast<N*>(pNf) && (!pName || pNf->name() == pName);
return (!pName || pNf->name() == pName) && (dynamic_cast<N*>(pNf) != nullptr);
}
bool accepts(const Notification::Ptr& pNf) const
{
return (pNf.cast<N>() != nullptr);
}
AbstractObserver* clone() const