Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __CQUE_H__
00020 #define __CQUE_H__
00021
00022 #include <string>
00023 #include <boost/cstdint.hpp>
00024 #include <boost/thread/mutex.hpp>
00025 #include <boost/thread/condition.hpp>
00026 #include <deque>
00027
00028 #include "getclocktime.hpp"
00029 #include "buffer.h"
00030 #include "network.h"
00031 #include "dsodefs.h"
00032
00033
00034 namespace gnash
00035 {
00036
00037 class CQue {
00038 public:
00039 typedef std::deque<boost::shared_ptr<cygnal::Buffer> > que_t;
00040 #ifdef USE_STATS_QUEUE
00041 typedef struct {
00042 struct timespec start;
00043 int totalbytes;
00044 int totalin;
00045 int totalout;
00046 } que_stats_t;
00047 #endif
00048 CQue();
00049 CQue(const std::string &str) { _name = str; };
00050 ~CQue();
00051
00052 bool push(boost::uint8_t *data, int nbytes);
00053 bool push(boost::shared_ptr<cygnal::Buffer> data);
00054
00055 boost::shared_ptr<cygnal::Buffer> DSOEXPORT pop();
00056
00057 boost::shared_ptr<cygnal::Buffer> DSOEXPORT peek();
00058
00059 size_t DSOEXPORT size();
00060
00061 void wait();
00062
00063 void notify();
00064
00065 void clear();
00066
00067 void remove(boost::shared_ptr<cygnal::Buffer> begin, boost::shared_ptr<cygnal::Buffer> end);
00068
00069
00070 void remove(boost::shared_ptr<cygnal::Buffer> it);
00071
00072
00073 boost::shared_ptr<cygnal::Buffer> DSOEXPORT merge(boost::shared_ptr<cygnal::Buffer> begin);
00074 boost::shared_ptr<cygnal::Buffer> DSOEXPORT merge();
00075
00076 boost::shared_ptr<cygnal::Buffer> operator[] (int index) { return _que[index]; };
00077
00078
00079 void dump();
00080 #ifdef USE_STATS_QUEUE
00081 que_stats_t *stats() { return &_stats; };
00082 #endif
00083 void setName(const std::string &str) { _name = str; }
00084 const std::string &getName() { return _name; }
00085 private:
00086
00087 std::string _name;
00088
00089 que_t _que;
00090
00091
00092 boost::condition _cond;
00093
00094
00095 boost::mutex _cond_mutex;
00096
00097 boost::mutex _mutex;
00098 #ifdef USE_STATS_QUEUE
00099 que_stats_t _stats;
00100 #endif
00101 };
00102
00103 }
00104
00105 #endif // end of __CQUE_H__
00106
00107
00108
00109
00110