00001 /*========================================================================== 00002 * Copyright (c) 2005 University of Massachusetts. All Rights Reserved. 00003 * 00004 * Use of the Lemur Toolkit for Language Modeling and Information Retrieval 00005 * is subject to the terms of the software license set forth in the LICENSE 00006 * file included with this software, and also available at 00007 * http://www.lemurproject.org/license.html 00008 * 00009 *========================================================================== 00010 */ 00011 00012 // 00013 // UtilityThread 00014 // 00015 // 31 January 2005 -- tds 00016 // 00017 00018 #ifndef INDRI_UTILITYTHREAD_HPP 00019 #define INDRI_UTILITYTHREAD_HPP 00020 00021 #include "indri/Thread.hpp" 00022 #include "indri/Mutex.hpp" 00023 #include "indri/ConditionVariable.hpp" 00024 namespace indri 00025 { 00026 namespace thread 00027 { 00028 class UtilityThread { 00029 private: 00030 Thread* _thread; 00031 Mutex _lock; 00032 ConditionVariable _quit; 00033 volatile bool _runThread; 00034 00035 public: 00036 UtilityThread(); 00037 virtual ~UtilityThread() {}; 00038 00039 virtual bool hasWork() = 0; 00040 virtual UINT64 work() = 0; 00041 virtual UINT64 initialize() = 0; 00042 virtual void deinitialize() = 0; 00043 00044 virtual void run(); 00045 virtual void start(); 00046 virtual void signal(); 00047 virtual void join(); 00048 }; 00049 } 00050 } 00051 00052 #endif // INDRI_UTILITYTHREAD_HPP 00053