Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MCThread.h

00001 #if !defined(__MCTHREAD_H_)
00002 #define __MCTHREAD_H_
00003 
00004 #ident "@(#)$Id: MCThread.h,v 1.6 2004/12/02 07:05:20 mike Exp $"
00005 
00006 /*
00007  * Copyright Miba Consulting Ltd. (c) 2000-2003
00008  * 
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  * 
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017  * Lesser General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00022  *
00023  */
00024 
00025 #include "mcllib/MCBase.h"
00026 #include "mcllib/MCString.h"
00027 #include "mcllib/MCTypes.h"
00028 #include "mcllib/MCThreadData.h"
00029 #include "mcllib/MCRunnable.h"
00030 
00031 namespace mcllib
00032 {
00041     class MCThread : public MCBase
00042     {
00043     public:
00045         enum EType {
00046             THRTYPEUSER,      
00047             THRTYPESYS        
00048         };
00050         enum EScope {
00051             THRSCOPELOCAL,    
00052             THRSCOPEGLOBAL,   
00053             THRSCOPEBOUND     
00054         };
00056         enum EState {
00057             THRSTATEJOIN,     
00058             THRSTATENOJOIN    
00059         };
00061         enum EPriority {
00062             THRPRILOW,        
00063             THRPRINORMAL,     
00064             THRPRIHIGH,       
00065             THRPRIURGENT      
00066         };
00070         MCThread();
00075         MCThread(const MCString& name);
00095         void start(MCRunnable* pRunnable,
00096                    EType type = THRTYPEUSER,
00097                    EScope scope = THRSCOPELOCAL,
00098                    EState state = THRSTATEJOIN,
00099                    EPriority pri = THRPRINORMAL,
00100                    mcstacksize_t sz = 0);
00106         void setPriority(EPriority pri);
00112         void setInterrupt();
00118         void join();
00126         const MCString& getName() const;
00135         mcthreadid_t getId() const;
00143         static MCRefPtr<MCThreadData> getData(mcthreaddatakey_t index);
00152         static void setData(mcthreaddatakey_t index, MCThreadData* pData);
00164         static void setDataAll(mcthreaddatakey_t index,
00165             MCThreadData* pData);
00178         static mcthreaddatakey_t getDataIndex(const MCString& key);
00184         static void sleep(mcinterval_t interval);
00190         static void yield();
00195         static void clearInterrupt();
00200         static MCThread getCurrentThread();
00201 
00202     private:
00203         // Construct a thread from an implementation object
00204         MCThread(void* impl);
00205         // These should only be called by a scoped critical region
00207         static void blockInterrupt();
00209         static void unblockInterrupt();
00210     };
00211 };
00212 
00213 
00214 #endif

Generated on Wed Jan 12 19:05:48 2005 for MCLLIB by  doxygen 1.3.9.1