#ifndef __COMMANDQUEUE__ #define __COMMANDQUEUE__ #include #include namespace Universal { struct QueueItem { /* QueueItem(int thread, int value):_thread(thread), _value(value){} int _thread; int _value; //*/ QueueItem(char *data, short data_len):_data(data), _data_len(data_len){} char *_data; short _data_len; //*/ }; // used to sync access to the queue class QueueAccessor { public: QueueAccessor(){} void Push(QueueItem item) { boost::mutex::scoped_lock scoped_lock(_mutex); _queue.push(item); } QueueItem Pop() { boost::mutex::scoped_lock scoped_lock(_mutex); if( _queue.size() > 0 ) { QueueItem tmp = _queue.front(); _queue.pop(); return tmp; } } std::queue::size_type Size() { boost::mutex::scoped_lock scoped_lock(_mutex); return _queue.size(); } private: boost::mutex _mutex; std::queue _queue; }; }// Universal namespace #endif // __COMMANDQUEUE__