15 #ifndef THREADSIMPLEMANAGER_H 16 #define THREADSIMPLEMANAGER_H 18 #include "pandabase.h" 19 #include "selectThreadImpl.h" 21 #ifdef THREAD_SIMPLE_IMPL 26 #include "trueClock.h" 27 #include "configVariableDouble.h" 30 #ifdef HAVE_POSIX_THREADS 34 #ifndef WIN32_LEAN_AND_MEAN 35 #define WIN32_LEAN_AND_MEAN 1 41 class ThreadSimpleImpl;
59 class EXPCL_PANDA_PIPELINE ThreadSimpleManager {
61 ThreadSimpleManager();
64 void enqueue_ready(ThreadSimpleImpl *thread,
bool volunteer);
65 void enqueue_sleep(ThreadSimpleImpl *thread,
double seconds);
66 void enqueue_block(ThreadSimpleImpl *thread, BlockerSimple *blocker);
67 bool unblock_one(BlockerSimple *blocker);
68 bool unblock_all(BlockerSimple *blocker);
69 void enqueue_finished(ThreadSimpleImpl *thread);
70 void preempt(ThreadSimpleImpl *thread);
73 void prepare_for_exit();
75 INLINE ThreadSimpleImpl *get_current_thread();
76 void set_current_thread(ThreadSimpleImpl *current_thread);
77 INLINE
bool is_same_system_thread()
const;
78 void remove_thread(ThreadSimpleImpl *thread);
79 static void system_sleep(
double seconds);
80 static void system_yield();
82 double get_current_time()
const;
83 INLINE
static ThreadSimpleManager *get_global_ptr();
85 void write_status(ostream &out)
const;
88 static void init_pointers();
93 static void st_choose_next_context(
struct ThreadContext *from_context,
void *data);
94 void choose_next_context(
struct ThreadContext *from_context);
95 void do_timeslice_accounting(ThreadSimpleImpl *thread,
double now);
96 void wake_sleepers(Sleeping &sleepers,
double now);
97 void wake_all_sleepers(Sleeping &sleepers);
98 void report_deadlock();
99 double determine_timeslice(ThreadSimpleImpl *chosen_thread);
100 void kill_non_joinable(FifoThreads &threads);
101 void kill_non_joinable(Sleeping &threads);
104 class CompareStartTime {
106 INLINE
bool operator ()(ThreadSimpleImpl *a, ThreadSimpleImpl *b)
const;
121 ThreadSimpleImpl *
volatile _current_thread;
130 FifoThreads _next_ready;
145 Sleeping _volunteers;
148 FifoThreads _finished;
150 ThreadSimpleImpl *_waiting_for_exit;
158 unsigned int _tick_count;
159 ThreadSimpleImpl *_thread;
162 TickRecords _tick_records;
163 unsigned int _total_ticks;
165 static bool _pointers_initialized;
166 static ThreadSimpleManager *_global_ptr;
171 #include "threadSimpleImpl.h" 173 #include "threadSimpleManager.I" 175 #endif // THREAD_SIMPLE_IMPL This is our own Panda specialization on the default STL map.
This is our own Panda specialization on the default STL deque.
This is our own Panda specialization on the default STL vector.
This is a convenience class to specialize ConfigVariable as a floating-point type.
An interface to whatever real-time clock we might have available in the current environment.
A thread; that is, a lightweight process.