views:

150

answers:

2

Based on this question I am going to use Poco::NamedEvent, but I need to wait for multiple events (like win32 WaitForMultipleObjects()

Is there such a thing in poco? (searching the docs doesn't yield much but perhaps I am not using the right searches)

+1  A: 

I don't think you'll find WaitForMultipleObjects() in any cross-platform package, including Poco. No Unix variant of which I am aware packages that kind of functionality in single API call but rather spreads it out depending on the kind of object you are waiting on.

Duck
they would all be the same class of object - in this case a NamedEvent.
Tim
@Tim You have probably looked already but NamedEvent is just a wrapper around CreateEvent or a semaphore depending on the platform. Not sure what you are doing but I don't see an easy way around this without coding your own clever hack.
Duck
Yeah - I grepped the source for waitformultipleobjects. I'll just start a thread for each event and wait on it. Not sure that is the best solution but it will work...
Tim
A: 

class NotificationQueue would let you queue up objects, and process them. It is better OOP to use IOC and delegates than to have a big WaitForMultipleObjects followed by a switch statement, anyways.

Warren P
Are you saying NotificationQueue works across processes? (http://pocoproject.org/docs/Poco.NotificationQueue.html)
Tim
Despite popular belief, "better OOP" doesn't always trump "does what I need".
jalf
@jalf - I couldn't agree more. A switch statement with 5 entries that calls a method for each one (an event handler) is no different than delegates. It is also simple to read and easy to maintain.
Tim
(for the record I voted this answer up)
Tim