NotificationThread.h

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #ifndef NOTIFICATION_THREAD_H_
00004 #define NOTIFICATION_THREAD_H_
00005 
00006 #include <fesa-core/Utilities/Thread.h>
00007 #include <fesa-core/Synchronization/MultiplexingContext.h>
00008 #include <fesa-core/Utilities/Mutex.h>
00009 #include <fesa-core/Utilities/ConditionalVariable.h>
00010 
00011 #include <vector>
00012 #include <string>
00013 #include <deque>
00014 #include <boost/shared_ptr.hpp>
00015 
00016 namespace fesa
00017 {
00018 
00019 class SubscriptionFilter;
00020 
00028 class NotificationThread : public Thread
00029 {
00030   public:
00031 
00036     NotificationThread(const std::string& className, const std::string& notificationThreadKey);
00037 
00041     virtual ~NotificationThread();
00042 
00049     void addNotificationEvent(MultiplexingContext& muxContext, RequestType& reqType,
00050                               std::vector<std::string>& validCS, SubscriptionFilter* subFilter);
00051 
00057     bool removeNotificationEvent(SubscriptionFilter* subFilter);
00058 
00062     Mutex& getMutex();
00063 
00064   private:
00065 
00070     void run();
00071 
00075     class NotificationQueueElement
00076     {
00077       public:
00078 
00085         NotificationQueueElement(MultiplexingContext& muxContext, RequestType& reqType,
00086                                  std::vector<std::string>& validCS, SubscriptionFilter* subFilter);
00087 
00091         ~NotificationQueueElement();
00092 
00096         SubscriptionFilter* subFilter_;
00097 
00101         MultiplexingContext muxContext_;
00102 
00106         RequestType reqType_;
00107 
00111         std::vector<std::string> validCS_;
00112     };
00113 
00117     std::deque<boost::shared_ptr<NotificationQueueElement> > queue_;
00118 
00119     SubscriptionFilter* inUseSubFilter_;
00120 
00124     Mutex mutexQueue_;
00125 
00130     Mutex mutexBackThread_;
00131 
00135     ConditionalVariable startConsumption_;
00136 };
00137 
00138 inline Mutex& NotificationThread::getMutex()
00139 {
00140     return mutexBackThread_;
00141 }
00142 
00143 } // fesa
00144 
00145 #endif // NOTIFICATION_THREAD_H_

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1