【发布时间】:2014-01-14 10:44:06
【问题描述】:
我开始使用Poco::NotificationQueue。我注意到这种奇怪的行为,如果多个工作线程使用waitDequeueNotification() 在同一个NotificationQueue 上等待,则只有一个线程接收到从主线程发送的通知。
如果您运行 Poco 提供的 NotificationQueue.cpp 示例,这一点很明显(在这种情况下是从 Visual Studio 完成的,但在 Linux 上测试的结果是相同的)。
它的输出是:
Worker 1 got work notification 0 Worker 3 got work notification 2 Worker 2 got work notification 1 Worker 1 got work notification 3 Worker 3 got work notification 4 Worker 2 got work notification 5 ...
预期结果是:
Worker 1 got work notification 0 Worker 3 got work notification 0 Worker 2 got work notification 0 Worker 1 got work notification 1 Worker 3 got work notification 1 Worker 2 got work notification 1 .....
这是一个错误还是什么?如果有,有什么解决办法吗?
【问题讨论】:
标签: c++ multithreading notifications poco