#ifndef _TR_QUEUE_H_ #define _TR_QUEUE_H_ #include #include #include #include #include #include using namespace std; class tr_queue { public: tr_queue(unsigned int size); ~tr_queue(); bool initialize(); unsigned int get(unsigned char *buffer, unsigned int len); unsigned int put(const unsigned char *buffer, unsigned int len); inline void clean() { m_nin = m_nout = 0; } inline unsigned int get_datalen() const { return m_nin - m_nout; } private: inline bool is_power_of_2(unsigned long n) { return (n != 0 && ((n & (n - 1)) == 0)); } inline unsigned long roundup_power_of_two(unsigned long val); private: unsigned int m_nsize; unsigned int m_nin; unsigned int m_nout; unsigned char* m_pbuffer; }; #endif