net/commandQueue.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef EQNET_COMMANDQUEUE_H
00019 #define EQNET_COMMANDQUEUE_H
00020
00021 #include <eq/base/lock.h>
00022 #include <eq/base/mtQueue.h>
00023 #include <eq/base/nonCopyable.h>
00024 #include <eq/base/thread.h>
00025
00026 namespace eq
00027 {
00028 namespace net
00029 {
00030 class Command;
00031
00035 class CommandQueue : public base::NonCopyable
00036 {
00037 public:
00038 EQ_EXPORT CommandQueue();
00039 EQ_EXPORT virtual ~CommandQueue();
00040
00046 EQ_EXPORT virtual void push( Command& packet );
00047
00049 EQ_EXPORT virtual void pushFront( Command& packet );
00050
00052 virtual void wakeup() { _commands.push( static_cast< Command* >( 0 )); }
00053
00061 EQ_EXPORT virtual Command* pop();
00062
00070 EQ_EXPORT virtual Command* tryPop();
00071
00077 EQ_EXPORT Command* back() const;
00078
00083 bool isEmpty() const { return _commands.isEmpty(); }
00084
00086 virtual void flush();
00087
00089 size_t getSize() const { return _commands.getSize(); }
00090
00091 CHECK_THREAD_DECLARE( _thread );
00092 private:
00094 base::MTQueue< Command* > _commands;
00095 };
00096 }
00097 }
00098
00099 #endif //EQNET_COMMANDQUEUE_H