Skip to content

Commit 98eae38

Browse files
committed
fix(AsyncNotificationCenter); remove default #4414
1 parent 71560b0 commit 98eae38

File tree

4 files changed

+9
-23
lines changed

4 files changed

+9
-23
lines changed

Foundation/include/Poco/AsyncNotificationCenter.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,9 @@ class Foundation_API AsyncNotificationCenter: public NotificationCenter
5454
/// Enqueues notification into the notification queue.
5555

5656
virtual int backlog() const;
57-
/// Rteurns the numbner of notifications in the notification queue.
57+
/// Returns the numbner of notifications in the notification queue.
5858

59-
static AsyncNotificationCenter& defaultCenter();
60-
61-
// TODO: see testDefaultAsyncNotificationCenter for details
62-
//private:
59+
private:
6360
void start();
6461
void stop();
6562
void dequeue();

Foundation/src/AsyncNotificationCenter.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,4 @@ void AsyncNotificationCenter::dequeue()
103103
}
104104

105105

106-
AsyncNotificationCenter& AsyncNotificationCenter::defaultCenter()
107-
{
108-
static AsyncNotificationCenter nc;
109-
return nc;
110-
}
111-
112-
113106
} // namespace Poco

Foundation/testsuite/src/NotificationCenterTest.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,32 +227,28 @@ void NotificationCenterTest::testDefaultNotificationCenter()
227227
}
228228

229229

230-
void NotificationCenterTest::testDefaultAsyncNotificationCenter()
230+
void NotificationCenterTest::testMixedObservers()
231231
{
232-
using ObserverT = AsyncObserver<NotificationCenterTest, TestNotification>::Type;
232+
using AObserverT = AsyncObserver<NotificationCenterTest, TestNotification>::Type;
233233

234-
AsyncNotificationCenter& nc = AsyncNotificationCenter::defaultCenter();
234+
AsyncNotificationCenter nc;
235235
nc.addObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
236236
nc.addObserver(NObserver<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handleAuto));
237-
nc.addObserver(ObserverT(*this, &NotificationCenterTest::handleAsync1, &NotificationCenterTest::matchAsync));
237+
nc.addObserver(AObserverT(*this, &NotificationCenterTest::handleAsync1, &NotificationCenterTest::matchAsync));
238238
nc.postNotification(new Notification);
239239
nc.postNotification(new TestNotification("asyncNotification"));
240240

241241
while (!_handle1Done || !_handleAuto1Done || !_handleAsync1Done)
242242
Poco::Thread::sleep(100);
243243

244-
nc.removeObserver(ObserverT(*this, &NotificationCenterTest::handleAsync1, &NotificationCenterTest::matchAsync));
244+
nc.removeObserver(AObserverT(*this, &NotificationCenterTest::handleAsync1, &NotificationCenterTest::matchAsync));
245245
nc.removeObserver(NObserver<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handleAuto));
246246
nc.removeObserver(Observer<NotificationCenterTest, Notification>(*this, &NotificationCenterTest::handle1));
247247
Poco::Mutex::ScopedLock l(_mutex);
248248
assertTrue (_set.size() == 3);
249249
assertTrue (_set.find("handle1") != _set.end());
250250
assertTrue (_set.find("handleAuto") != _set.end());
251251
assertTrue (_set.find("handleAsync1") != _set.end());
252-
// TODO: static object thread hangs without this on windows
253-
// for explanation/solution, see
254-
// https://stackoverflow.com/questions/10441048/exit-thread-upon-deleting-static-object-during-unload-dll-causes-deadlock
255-
nc.stop();
256252
}
257253

258254

@@ -344,7 +340,7 @@ CppUnit::Test* NotificationCenterTest::suite()
344340
CppUnit_addTest(pSuite, NotificationCenterTest, testAsyncObserver);
345341
CppUnit_addTest(pSuite, NotificationCenterTest, testAsyncNotificationCenter);
346342
CppUnit_addTest(pSuite, NotificationCenterTest, testDefaultNotificationCenter);
347-
CppUnit_addTest(pSuite, NotificationCenterTest, testDefaultAsyncNotificationCenter);
343+
CppUnit_addTest(pSuite, NotificationCenterTest, testMixedObservers);
348344

349345
return pSuite;
350346
}

Foundation/testsuite/src/NotificationCenterTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class NotificationCenterTest: public CppUnit::TestCase
4040
void testAsyncObserver();
4141
void testAsyncNotificationCenter();
4242
void testDefaultNotificationCenter();
43-
void testDefaultAsyncNotificationCenter();
43+
void testMixedObservers();
4444

4545
void setUp();
4646
void tearDown();

0 commit comments

Comments
 (0)