123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #ifndef _TR_QUEUE_H_
- #define _TR_QUEUE_H_
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <string>
- #include <pthread.h>
- #include <iostream>
- 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
|