net/commandQueue.h

00001 
00002 /* Copyright (c) 2005-2009, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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
Generated on Mon Aug 10 18:58:32 2009 for Equalizer 0.9 by  doxygen 1.5.8