Equalizer  1.4.1
worker.h
00001 
00002 /* Copyright (c) 2011, Stefan Eilemann <eile@eyescale.ch> 
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 CO_WORKER_H
00019 #define CO_WORKER_H
00020 
00021 #include <co/api.h>          // CO_API definition
00022 #include <co/types.h>
00023 #include <lunchbox/thread.h>  // base class
00024 
00025 #ifndef CO_WORKER_API
00026 #  define CO_WORKER_API CO_API
00027 #endif
00028 
00029 namespace co
00030 {
00032     template< class Q > class WorkerThread : public lunchbox::Thread
00033     {
00034     public:
00036         WorkerThread() {}
00037 
00039         virtual ~WorkerThread() {}
00040 
00042         Q* getWorkerQueue() { return &_commands; }
00043 
00044     protected:
00046         virtual bool init()
00047             {
00048                 setName( lunchbox::className( this ));
00049                 return true;
00050             }
00051 
00053         CO_WORKER_API virtual void run();
00054 
00056         virtual bool stopRunning() { return false; }
00057         
00059         virtual bool notifyIdle() { return false; }
00060 
00061     private:
00063         Q _commands;
00064     };
00065 
00066     typedef WorkerThread< CommandQueue > Worker; // instantiated in worker.cpp
00067 }
00068 #endif //CO_WORKER_H
Generated on Mon Nov 26 2012 14:41:50 for Equalizer 1.4.1 by  doxygen 1.7.6.1