eXpress “1.5”

src/threadsafety.h

00001 
00009 #ifndef express_thread_safety_h
00010 #define express_thread_safety_h
00011 
00012 #include <boost/thread.hpp>
00013 #include <queue>
00014 
00015 class Fragment;
00016 
00023 class ThreadSafeFragQueue {
00027   std::queue<Fragment*> _queue;
00032   size_t _max_size;
00037   boost::mutex _mut;
00042   boost::condition_variable _cond;
00043 
00044  public:
00051   ThreadSafeFragQueue(size_t max_size);
00061   Fragment* pop(bool block=true);
00067   void push(Fragment* frag);
00075   bool is_empty(bool block=false);
00076 };
00077 
00085 struct ParseThreadSafety {
00090   ThreadSafeFragQueue proc_in;
00095   ThreadSafeFragQueue proc_on;
00100   ThreadSafeFragQueue proc_out;
00105   ParseThreadSafety(size_t q_size)
00106       : proc_in(q_size), proc_on(q_size), proc_out(q_size) {
00107   }
00108 };
00109 
00110 #endif
 All Classes Functions Variables