diff --git a/Foundation/include/Poco/AsyncNotificationCenter.h b/Foundation/include/Poco/AsyncNotificationCenter.h index f5434aa06c..7bf8ded1b7 100644 --- a/Foundation/include/Poco/AsyncNotificationCenter.h +++ b/Foundation/include/Poco/AsyncNotificationCenter.h @@ -54,12 +54,9 @@ class Foundation_API AsyncNotificationCenter: public NotificationCenter /// Enqueues notification into the notification queue. virtual int backlog() const; - /// Rteurns the numbner of notifications in the notification queue. + /// Returns the numbner of notifications in the notification queue. - static AsyncNotificationCenter& defaultCenter(); - -// TODO: see testDefaultAsyncNotificationCenter for details -//private: +private: void start(); void stop(); void dequeue(); diff --git a/Foundation/src/AsyncNotificationCenter.cpp b/Foundation/src/AsyncNotificationCenter.cpp index 9fb216c6d7..61fbb91134 100644 --- a/Foundation/src/AsyncNotificationCenter.cpp +++ b/Foundation/src/AsyncNotificationCenter.cpp @@ -103,11 +103,4 @@ void AsyncNotificationCenter::dequeue() } -AsyncNotificationCenter& AsyncNotificationCenter::defaultCenter() -{ - static AsyncNotificationCenter nc; - return nc; -} - - } // namespace Poco diff --git a/Foundation/testsuite/src/NotificationCenterTest.cpp b/Foundation/testsuite/src/NotificationCenterTest.cpp index f279efa425..018c3d44df 100644 --- a/Foundation/testsuite/src/NotificationCenterTest.cpp +++ b/Foundation/testsuite/src/NotificationCenterTest.cpp @@ -227,21 +227,21 @@ void NotificationCenterTest::testDefaultNotificationCenter() } -void NotificationCenterTest::testDefaultAsyncNotificationCenter() +void NotificationCenterTest::testMixedObservers() { - using ObserverT = AsyncObserver::Type; + using AObserverT = AsyncObserver::Type; - AsyncNotificationCenter& nc = AsyncNotificationCenter::defaultCenter(); + AsyncNotificationCenter nc; nc.addObserver(Observer(*this, &NotificationCenterTest::handle1)); nc.addObserver(NObserver(*this, &NotificationCenterTest::handleAuto)); - nc.addObserver(ObserverT(*this, &NotificationCenterTest::handleAsync1, &NotificationCenterTest::matchAsync)); + nc.addObserver(AObserverT(*this, &NotificationCenterTest::handleAsync1, &NotificationCenterTest::matchAsync)); nc.postNotification(new Notification); nc.postNotification(new TestNotification("asyncNotification")); while (!_handle1Done || !_handleAuto1Done || !_handleAsync1Done) Poco::Thread::sleep(100); - nc.removeObserver(ObserverT(*this, &NotificationCenterTest::handleAsync1, &NotificationCenterTest::matchAsync)); + nc.removeObserver(AObserverT(*this, &NotificationCenterTest::handleAsync1, &NotificationCenterTest::matchAsync)); nc.removeObserver(NObserver(*this, &NotificationCenterTest::handleAuto)); nc.removeObserver(Observer(*this, &NotificationCenterTest::handle1)); Poco::Mutex::ScopedLock l(_mutex); @@ -249,10 +249,6 @@ void NotificationCenterTest::testDefaultAsyncNotificationCenter() assertTrue (_set.find("handle1") != _set.end()); assertTrue (_set.find("handleAuto") != _set.end()); assertTrue (_set.find("handleAsync1") != _set.end()); - // TODO: static object thread hangs without this on windows - // for explanation/solution, see - // https://stackoverflow.com/questions/10441048/exit-thread-upon-deleting-static-object-during-unload-dll-causes-deadlock - nc.stop(); } @@ -344,7 +340,7 @@ CppUnit::Test* NotificationCenterTest::suite() CppUnit_addTest(pSuite, NotificationCenterTest, testAsyncObserver); CppUnit_addTest(pSuite, NotificationCenterTest, testAsyncNotificationCenter); CppUnit_addTest(pSuite, NotificationCenterTest, testDefaultNotificationCenter); - CppUnit_addTest(pSuite, NotificationCenterTest, testDefaultAsyncNotificationCenter); + CppUnit_addTest(pSuite, NotificationCenterTest, testMixedObservers); return pSuite; } diff --git a/Foundation/testsuite/src/NotificationCenterTest.h b/Foundation/testsuite/src/NotificationCenterTest.h index ee094f2243..080c30796a 100644 --- a/Foundation/testsuite/src/NotificationCenterTest.h +++ b/Foundation/testsuite/src/NotificationCenterTest.h @@ -40,7 +40,7 @@ class NotificationCenterTest: public CppUnit::TestCase void testAsyncObserver(); void testAsyncNotificationCenter(); void testDefaultNotificationCenter(); - void testDefaultAsyncNotificationCenter(); + void testMixedObservers(); void setUp(); void tearDown();