Main Page | Namespace List | 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         return Identifier((uint64_t)pthread_self());
00042     }
00043 
00044     Identifier identifier() const {
00045         return Identifier((uint64_t)mThread);
00046     }
00047 
00048 private:
00049     static void* exec(void *threadPtr);
00050     void* exec(void);
00051 
00052     String mName;
00053     pthread_t mThread;
00054     pthread_cond_t mCond;
00055     pthread_mutex_t mMutex;
00056     bool mRunning;
00057 
00058     void *(*pCallback)(void *);
00059     void *pArg;
00060     void *mRet;
00061 };
00062 }
00063 ;// namespace Phx
00064 #endif /* PHX_THREAD_H */

Generated on Wed Dec 21 22:05:37 2005 for Phoenix OSFS by  doxygen 1.4.2