|Returns the number of notifications in the queue. |
|Notification *||dequeueNotification ()|
|void||dispatch (NotificationCenter ¬ificationCenter)|
|bool||empty () const|
|Wakes up all threads that wait for a notification. |
|void||enqueueNotification (Notification::Ptr pNotification, int priority)|
|Destroys the PriorityNotificationQueue. |
|bool||hasIdleThreads () const|
|Removes all notifications from the queue. |
|int||size () const|
|Returns true iff the queue is empty. |
|Notification *||waitDequeueNotification ()|
|Notification *||waitDequeueNotification (long milliseconds)|
|Creates the PriorityNotificationQueue. |
|static PriorityNotificationQueue &||defaultQueue ()|
typedef std::multimap< int, |
|typedef std::deque< WaitInfo * >||WaitQueue|
A PriorityNotificationQueue object provides a way to implement asynchronous notifications. This is especially useful for sending notifications from one thread to another, for example from a background thread to the main (user interface) thread.
The PriorityNotificationQueue is quite similar to the NotificationQueue class. The only difference to NotificationQueue is that each Notification is tagged with a priority value. When inserting a Notification into the queue, the Notification is inserted according to the given priority value, with lower priority values being inserted before higher priority values. Therefore, the lower the numerical priority value, the higher the actual notification priority.
Notifications are dequeued in order of their priority.
The PriorityNotificationQueue can also be used to distribute work from a controlling thread to one or more worker threads. Each worker thread repeatedly calls waitDequeueNotification() and processes the returned notification. Special care must be taken when shutting down a queue with worker threads waiting for notifications. The recommended sequence to shut down and destroy the queue is to 1. set a termination flag for every worker thread 2. call the wakeUpAll() method 3. join each worker thread 4. destroy the notification queue.