00001 //******************************************************************************* 00002 // 00003 // ******* *** *** * 00004 // * * * * 00005 // * * * ***** 00006 // * * *** * * ** * ** *** 00007 // * * * * * * * **** * * * 00008 // * * * * * * * * * * * 00009 // * *** *** * ** ** ** * * 00010 // * 00011 //******************************************************************************* 00012 // see http://sourceforge.net/projects/tcsystem/ for details. 00013 // Copyright (C) 2003 - 2008 Thomas Goessler. All Rights Reserved. 00014 //******************************************************************************* 00015 // 00016 // TCSystem is the legal property of its developers. 00017 // Please refer to the COPYRIGHT file distributed with this source distribution. 00018 // 00019 // This library is free software; you can redistribute it and/or 00020 // modify it under the terms of the GNU Lesser General Public 00021 // License as published by the Free Software Foundation; either 00022 // version 2.1 of the License, or (at your option) any later version. 00023 // 00024 // This library is distributed in the hope that it will be useful, 00025 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00026 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00027 // Lesser General Public License for more details. 00028 // 00029 // You should have received a copy of the GNU Lesser General Public 00030 // License along with this library; if not, write to the Free Software 00031 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00032 //******************************************************************************* 00033 // $Id: TCMTThread.h 870 2008-07-21 14:15:33Z the_____tiger $ 00034 //******************************************************************************* 00035 00036 #ifndef _TC_MT_THREAD_H_ 00037 #define _TC_MT_THREAD_H_ 00038 00039 #include "TCMTMessage.h" 00040 #include "TCMTThreadObject.h" 00041 #include "TCNonCopyable.h" 00042 00043 #include <string> 00044 #include <vector> 00045 00046 namespace TC 00047 { 00048 namespace MT 00049 { 00050 class Message; 00051 typedef SharedPtr<Message> MessagePtr; 00052 00067 class Thread: protected NonCopyAble 00068 { 00069 public: 00071 enum ThreadPriority 00072 { 00073 PRIORITY_LOWEST, 00074 PRIORITY_LOW, 00075 PRIORITY_NORMAL, 00076 PRIORITY_HIGH, 00077 PRIORITY_HIGHEST 00078 }; 00079 00081 enum ThreadState 00082 { 00084 STATE_NEW, 00086 STATE_RUNNING, 00089 STATE_TERMINATED 00090 }; 00091 00092 public: 00094 virtual ~Thread() {} 00095 00101 virtual bool Start(ThreadObjectPtr object_to_start) = 0; 00106 virtual bool Join() = 0; 00107 00109 virtual bool IsRunning() const = 0; 00111 virtual bool IsTerminated() const = 0; 00112 00114 virtual bool SetPriority(ThreadPriority priority) = 0; 00116 virtual ThreadPriority GetPriority() const = 0; 00117 00129 virtual bool SendThreadMessage(MessagePtr message) = 0; 00130 00136 virtual Message::ReturnValue WaitThreadMessage(MessagePtr &message) = 0; 00143 virtual Message::ReturnValue WaitThreadMessage(MessagePtr &message, uint32 timeout) = 0; 00147 }; 00148 00150 typedef SharedPtr< Thread > ThreadPtr; 00151 00156 } // namespace MT 00157 } // namespace TC 00158 00159 00160 #endif // _TC_MT_THREAD_H_