15 #ifndef THREADSIMPLEIMPL_H 16 #define THREADSIMPLEIMPL_H 18 #include "pandabase.h" 19 #include "selectThreadImpl.h" 21 #ifdef THREAD_SIMPLE_IMPL 24 #include "threadPriority.h" 26 #include "contextSwitch.h" 30 #undef _POSIX_C_SOURCE 36 class ThreadSimpleManager;
37 class MutexSimpleImpl;
61 class EXPCL_PANDA_PIPELINE ThreadSimpleImpl {
63 ThreadSimpleImpl(
Thread *parent_obj);
66 void setup_main_thread();
67 bool start(ThreadPriority priority,
bool joinable);
71 string get_unique_id()
const;
73 static void prepare_for_exit();
75 INLINE
static Thread *get_current_thread();
76 INLINE
bool is_same_system_thread()
const;
78 INLINE
static void bind_thread(
Thread *thread);
79 INLINE
static bool is_threading_supported();
80 INLINE
static bool is_true_threads();
81 INLINE
static bool is_simple_threads();
82 INLINE
static void sleep(
double seconds);
83 INLINE
static void yield();
84 INLINE
static void consider_yield();
86 void sleep_this(
double seconds);
87 void yield_this(
bool volunteer);
88 INLINE
void consider_yield_this();
90 INLINE
double get_wake_time()
const;
92 INLINE
static void write_status(ostream &out);
95 static void st_begin_thread(
void *data);
106 static int _next_unique_id;
110 ThreadStatus _status;
111 ThreadPriority _priority;
115 double _priority_weight;
118 unsigned int _run_ticks;
131 ThreadContext *_context;
132 unsigned char *_stack;
138 PyThreadState *_python_state;
139 #endif // HAVE_PYTHON 143 JoiningThreads _joining_threads;
145 ThreadSimpleManager *_manager;
146 static ThreadSimpleImpl *
volatile _st_this;
155 #ifdef HAVE_POSIX_THREADS 156 pthread_t _posix_system_thread_id;
159 DWORD _win32_system_thread_id;
162 friend class ThreadSimpleManager;
167 #include "threadSimpleManager.h" 169 #include "threadSimpleImpl.I" 171 #endif // THREAD_SIMPLE_IMPL This is our own Panda specialization on the default STL vector.
A thread; that is, a lightweight process.