Overview
Features
Download
Documentation
Community
Add-Ons & Services

Notifications not sent multiple worker-threads

Please post support and help requests here.

Notifications not sent multiple worker-threads

Postby throstur62 » 14 Jan 2014, 12:39

Hi,
I'm starting using Poco::NotificationQueue. I have noticed that strange behavior, if more than one worker-threads are waiting on the same NotificationQueue using waitDequeueNotification(), only one of the tread receives a notification sent from a master-thread.
This is obvious if you run the NotificationQueue.cpp example provided with Poco (in this case done from Visual Studio, but the result is the same when tested on Linux).
The output from it is :
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
...
Expected result would be:
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
.....
Is this a bug or what? If so is there any workaround?
throstur62
 
Posts: 11
Joined: 22 Nov 2012, 18:44

Re: Notifications not sent multiple worker-threads

Postby guenter » 14 Jan 2014, 12:45

This is how it's supposed to work. NotificationQueue is used to distribute work to worker threads, and a (work) notification should only be received by one thread, which then works on that. If you need to distribute the same notification to multiple threads, use a separate NotificationQueue for each thread, combined with a NotificationCenter (each queue will subscribe to the NotificationCenter, so you only have to post one notification to the NC).
guenter
 
Posts: 1110
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Notifications not sent multiple worker-threads

Postby throstur62 » 14 Jan 2014, 14:27

Ok, my misunderstanding. Thank you.
throstur62
 
Posts: 11
Joined: 22 Nov 2012, 18:44


Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron