DgmQueue.h
Go to the documentation of this file.
00001 #ifndef DGM_QUEUE_H
00002 #define DGM_QUEUE_H
00003 
00004 #include <map>
00005 #include <pthread.h>
00006 #include "Datagram.h"
00007 
00008 
00009 class DgmQueue
00010 {
00011     protected:
00012         typedef std::multimap< unsigned char,Datagram, 
00013                 std::less<unsigned char> > Queue;
00014 
00015         Queue Q;
00016         pthread_mutex_t Qmtx;
00017         pthread_cond_t Qcnd;
00018         unsigned int verbose;
00019 
00020         bool interesting[256];
00021 
00022         void lock() {
00023             //printf("T %08X locking queue\n",(int)pthread_self());
00024             pthread_mutex_lock(&Qmtx);
00025             //printf("T %08X queue locked\n",(int)pthread_self());
00026         }
00027         void unlock() {
00028             //printf("T %08X unlocking queue\n",(int)pthread_self());
00029             pthread_mutex_unlock(&Qmtx);
00030             //printf("T %08X queue unlocked\n",(int)pthread_self());
00031         }
00032 
00033     public :
00034         DgmQueue();
00035         ~DgmQueue();
00036 
00037         void addInteresting(unsigned int i);
00038         void remInteresting(unsigned int i);
00039         void resetInteresting();
00040 
00041         void storeDgm(const Datagram & dgm);
00042 
00043         bool waitDgm(unsigned int id, Datagram & dgm, double maxwait_s=-1);
00044 
00045         void print();
00046 
00047         void setVerboseLevel(unsigned int v) {verbose=v; }
00048 };
00049 
00050 
00051 
00052 
00053 #endif // DGM_QUEUE_H


canon_vbc50i
Author(s): Cedric Pradalier
autogenerated on Sun Oct 5 2014 23:47:45