27typedef struct _JNIEnv JNIEnv;
33class ConditionVarDebug;
34class ConditionVarFullDebug;
46class EXPCL_PANDA_PIPELINE Thread :
public TypedReferenceCount,
public Namable {
48 Thread(
const std::string &name,
const std::string &sync_name);
49 Thread(
const Thread ©) =
delete;
55 Thread &operator = (
const Thread ©) =
delete;
57 virtual void thread_main()=0;
60 static PT(Thread) bind_thread(
const std::string &name,
const std::string &sync_name);
79 BLOCKING INLINE
static void sleep(
double seconds);
84 virtual void output(std::ostream &out)
const;
86 static void write_status(std::ostream &out);
91 bool start(ThreadPriority priority,
bool joinable);
92 BLOCKING INLINE
void join();
135 INLINE JNIEnv *get_jni_env()
const;
139 static void init_main_thread();
140 static void init_external_thread();
146 std::string _sync_name;
152 AtomicAdjust::Pointer _current_task;
157 MutexDebug *_blocked_on_mutex;
158 ConditionVarDebug *_waiting_on_cvar;
159 ConditionVarFullDebug *_waiting_on_cvar_full;
163 static Thread *_main_thread;
164 static Thread *_external_thread;
170 static void init_type() {
171 TypedReferenceCount::init_type();
172 Namable::init_type(),
174 TypedReferenceCount::get_class_type(),
175 Namable::get_class_type());
177 virtual TypeHandle get_type()
const {
178 return get_class_type();
180 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
183 static TypeHandle _type_handle;
185 friend class MutexDebug;
186 friend class ConditionVarDebug;
187 friend class ConditionVarFullDebug;
189 friend class ThreadDummyImpl;
190 friend class ThreadWin32Impl;
191 friend class ThreadPosixImpl;
192 friend class ThreadSimpleImpl;
193 friend class MainThread;
194 friend class AsyncTask;
197INLINE std::ostream &operator << (std::ostream &out,
const Thread &thread);
This class represents a concrete task performed by an AsyncManager.
A standard mutex, or mutual exclusion lock.
void output(std::ostream &out) const
Outputs the Namable.
virtual void deactivate_hook(Thread *thread)
Called when the thread is deactivated (swapped for another running thread).
virtual void activate_hook(Thread *thread)
Called when the thread is activated (resumes execution).
A thread; that is, a lightweight process.
void preempt()
Indicates that this thread should run as soon as possible, preemptying any other threads that may be ...
static void sleep(double seconds)
Suspends the current thread for at least the indicated amount of time.
get_python_index
Returns the Python index associated with this thread, or -1 if no index has yet been associated with ...
is_simple_threads
Returns true if Panda is currently compiled for "simple threads", which is to say,...
void output_blocker(std::ostream &out) const
Writes a description of the mutex or condition variable that this thread is blocked on.
get_pipeline_stage
Returns the Pipeline stage number associated with this thread.
is_joinable
Returns the value of joinable that was passed to the start() call.
void set_python_index(int index)
Stores a Python index to be associated with this thread.
is_threading_supported
Returns true if threading support has been compiled in and enabled, or false if no threading is avail...
get_current_task
Returns the task currently executing on this thread (via the AsyncTaskManager), if any,...
get_sync_name
Returns the sync name of the thread.
void join()
Blocks the calling process until the thread terminates.
void set_pstats_index(int pstats_index)
Stores a PStats index to be associated with this thread.
get_current_pipeline_stage
Returns the integer pipeline stage associated with the current thread.
get_main_thread
Returns a pointer to the "main" Thread object–this is the Thread that started the whole process.
static void consider_yield()
Possibly suspends the current thread for the rest of the current epoch, if it has run for enough this...
set_pipeline_stage
Specifies the Pipeline stage number associated with this thread.
void set_min_pipeline_stage(int min_pipeline_stage)
Sets this thread's pipeline stage number to at least the indicated value, unless it is already larger...
is_true_threads
Returns true if a real threading library is available that supports actual OS-implemented threads,...
get_external_thread
Returns a pointer to the "external" Thread object–this is a special Thread object that corresponds to...
bool start(ThreadPriority priority, bool joinable)
Starts the thread executing.
get_current_thread
Returns a pointer to the currently-executing Thread object.
void set_pstats_callback(PStatsCallback *pstats_callback)
Stores a PStats callback to be associated with this thread.
get_pstats_index
Returns the PStats index associated with this thread, or -1 if no index has yet been associated with ...
PStatsCallback * get_pstats_callback() const
Returns the PStats callback associated with this thread, or NULL if no callback has yet been associat...
static void prepare_for_exit()
Should be called by the main thread just before exiting the program, this blocks until any remaining ...
is_started
Returns true if the thread has been started, false if it has not, or if join() has already been calle...
get_unique_id
Returns a string that is guaranteed to be unique to this thread, across all processes on the machine,...
static void force_yield()
Suspends the current thread for the rest of the current epoch.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.