00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef THREAD_H
00020 #define THREAD_H
00021
00022 #include "pandabase.h"
00023 #include "typedReferenceCount.h"
00024 #include "threadPriority.h"
00025 #include "threadImpl.h"
00026 #include "notify.h"
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 class EXPCL_PANDAEXPRESS Thread : public TypedReferenceCount {
00041 public:
00042 INLINE Thread(const string &name);
00043 virtual ~Thread();
00044
00045 private:
00046 INLINE Thread(const Thread ©);
00047 INLINE void operator = (const Thread ©);
00048
00049 protected:
00050 virtual void thread_main()=0;
00051
00052 public:
00053 INLINE const string &get_name() const;
00054
00055 INLINE bool start(ThreadPriority priority, bool global, bool joinable);
00056 INLINE void join();
00057
00058 INLINE static void prepare_for_exit();
00059
00060 INLINE static Thread *get_current_thread();
00061 INLINE static bool is_threading_supported();
00062 INLINE static void sleep(double seconds);
00063
00064 virtual void output(ostream &out) const;
00065
00066 private:
00067 bool _started;
00068 string _name;
00069 ThreadImpl _impl;
00070 friend class ThreadDummyImpl;
00071 friend class ThreadNsprImpl;
00072
00073
00074 public:
00075 static TypeHandle get_class_type() {
00076 return _type_handle;
00077 }
00078 static void init_type() {
00079 TypedReferenceCount::init_type();
00080 register_type(_type_handle, "Thread",
00081 TypedReferenceCount::get_class_type());
00082 }
00083
00084 private:
00085 static TypeHandle _type_handle;
00086 };
00087
00088 INLINE ostream &operator << (ostream &out, const Thread &thread);
00089
00090 #include "thread.I"
00091
00092 #endif