00001
00002
00003
00004
00005 #ifndef EQNET_COMMANDQUEUE_H
00006 #define EQNET_COMMANDQUEUE_H
00007
00008 #include <eq/net/commandCache.h>
00009
00010 #include <eq/base/lock.h>
00011 #include <eq/base/mtQueue.h>
00012 #include <eq/base/nonCopyable.h>
00013 #include <eq/base/thread.h>
00014
00015 namespace eq
00016 {
00017 namespace net
00018 {
00019 class Command;
00020
00024 class EQ_EXPORT CommandQueue : public base::NonCopyable
00025 {
00026 public:
00027 CommandQueue();
00028 virtual ~CommandQueue();
00029
00035 virtual void push( Command& packet );
00036
00038 virtual void pushFront( Command& packet );
00039
00041 virtual void wakeup() { _commands.push( static_cast< Command* >( 0 )); }
00042
00050 virtual Command* pop();
00051
00059 virtual Command* tryPop();
00060
00062 void release( Command* command );
00063
00069 Command* back() const;
00070
00075 bool empty() const { return _commands.empty(); }
00076
00078 virtual void flush();
00079
00081 size_t size() const { return _commands.size(); }
00082
00083 CHECK_THREAD_DECLARE( _thread );
00084 private:
00086 base::MTQueue< Command* > _commands;
00087
00089 CommandCache _commandCache;
00090 base::Lock _commandCacheLock;
00091 };
00092 }
00093 }
00094
00095 #endif //EQNET_COMMANDQUEUE_H