Logo Search packages:      
Sourcecode: poco version File versions

Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Attributes

Poco::PriorityNotificationQueue Class Reference

#include <PriorityNotificationQueue.h>

Collaboration diagram for Poco::PriorityNotificationQueue:
Collaboration graph

List of all members.


struct  WaitInfo

Public Member Functions

void clear ()
 Returns the number of notifications in the queue.
NotificationdequeueNotification ()
void dispatch (NotificationCenter &notificationCenter)
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.
NotificationwaitDequeueNotification ()
NotificationwaitDequeueNotification (long milliseconds)
void wakeUpAll ()
 ~PriorityNotificationQueue ()
 Creates the PriorityNotificationQueue.

Static Public Member Functions

static PriorityNotificationQueuedefaultQueue ()

Protected Member Functions

Notification::Ptr dequeueOne ()

Private Types

typedef std::multimap< int,
typedef std::deque< WaitInfo * > WaitQueue

Private Attributes

FastMutex _mutex
NfQueue _nfQueue
WaitQueue _waitQueue

Detailed Description

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.

Definition at line 57 of file PriorityNotificationQueue.h.

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index