Equalizer
1.2.1
|
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 <co/base/thread.h> // base class 00024 00025 namespace co 00026 { 00028 template< class Q > class WorkerThread : public base::Thread 00029 { 00030 public: 00032 WorkerThread() {} 00033 00035 virtual ~WorkerThread() {} 00036 00038 Q* getWorkerQueue() { return &_commands; } 00039 00040 protected: 00042 virtual bool init() 00043 { 00044 setName( base::className( this )); 00045 return true; 00046 } 00047 00049 virtual void run(); 00050 00052 virtual bool stopRunning() { return false; } 00053 00055 virtual bool notifyIdle() { return false; } 00056 00057 private: 00059 Q _commands; 00060 }; 00061 00062 typedef WorkerThread< CommandQueue > Worker; // instantiated in worker.cpp 00063 } 00064 #endif //CO_WORKER_H