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

PhxThread.h

00001 //
00002 // C++ Interface: PhxThread
00003 //
00004 // Description:
00005 //
00006 //
00007 // Author: David AAberg <davabe@hotmail.com>, (C) 2005
00008 //
00009 // Copyright: See COPYING file that comes with this distribution
00010 //
00011 //
00012 #ifndef PHX_THREAD_H
00013 #define PHX_THREAD_H
00014 
00015 #include <Phx/PhxConfig.h> // also includes pthread.h
00016 #include <Phx/PhxTypes.h>
00017 
00018 namespace Phx {
00019 class Thread :public LockedPtrInterface<Thread> {
00020     class IdentifierClass;
00021 public:
00023     Thread(String name, void* (*callback)(void *),void* arg);
00025     ~Thread();
00026 
00028     const String& name(void);
00029 
00031     void kill(void);
00032 
00036     void* join(long timeout);
00037 
00038     typedef ValueType<IdentifierClass,uint64_t> Identifier;
00039 
00040     static Identifier current() {
00041 #if defined( PHX_PLATFORM_WIN32 )
00042         return Identifier((uint64_t)pthread_self().p);
00043 #else
00044         return Identifier((uint64_t)pthread_self());
00045 #endif
00046     }
00047 
00048     Identifier identifier() const {
00049 #if defined( PHX_PLATFORM_WIN32 )
00050                 return( Identifier( (uint64_t)mThread.p ) );
00051 #else
00052         return Identifier((uint64_t)mThread);
00053 #endif
00054     }
00055 
00056 private:
00057     static void* exec(void *threadPtr);
00058     void* exec(void);
00059 
00060     String mName;
00061     pthread_t mThread;
00062     pthread_cond_t mCond;
00063     pthread_mutex_t mMutex;
00064     bool mRunning;
00065 
00066     void *(*pCallback)(void *);
00067     void *pArg;
00068     void *mRet;
00069 };
00070 }
00071 ;// namespace Phx
00072 #endif /* PHX_THREAD_H */

Generated on Mon Jul 10 19:45:29 2006 for Phoenix OSFS by  doxygen 1.4.2