Go to the documentation of this file.
22 Thread *Thread::_main_thread;
23 Thread *Thread::_external_thread;
39 Thread(
const std::string &name,
const std::string &sync_name) :
41 _sync_name(sync_name),
47 _pstats_callback =
nullptr;
50 _current_task =
nullptr;
53 _blocked_on_mutex =
nullptr;
54 _waiting_on_cvar =
nullptr;
55 _waiting_on_cvar_full =
nullptr;
65 nassertv(_blocked_on_mutex ==
nullptr &&
66 _waiting_on_cvar ==
nullptr &&
67 _waiting_on_cvar_full ==
nullptr);
90 bind_thread(
const std::string &name,
const std::string &sync_name) {
94 nassertr(current_thread->get_name() == name &&
95 current_thread->
get_sync_name() == sync_name, current_thread);
96 return current_thread;
100 ThreadImpl::bind_thread(thread);
116 #ifdef THREADED_PIPELINE
117 _pipeline_stage = pipeline_stage;
119 if (pipeline_stage != 0) {
120 pipeline_cat.warning()
121 <<
"Requested pipeline stage " << pipeline_stage
122 <<
" but multithreaded render pipelines not enabled in build.\n";
132 output(std::ostream &out)
const {
133 out << get_type() <<
" " << get_name();
144 if (_blocked_on_mutex !=
nullptr) {
145 _blocked_on_mutex->output_with_holder(out);
146 }
else if (_waiting_on_cvar !=
nullptr) {
147 out << *_waiting_on_cvar;
148 }
else if (_waiting_on_cvar_full !=
nullptr) {
149 out << *_waiting_on_cvar_full;
151 #endif // DEBUG_THREADS
158 write_status(std::ostream &out) {
159 #if defined(HAVE_THREADS) && defined(SIMPLE_THREADS)
160 ThreadImpl::write_status(out);
184 start(ThreadPriority priority,
bool joinable) {
185 nassertr(!_started,
false);
187 if (!support_threads) {
188 thread_cat->warning()
189 << *
this <<
" could not be started: support-threads is false.\n";
193 _joinable = joinable;
194 _started = _impl.start(priority, joinable);
197 thread_cat->warning()
198 << *
this <<
" could not be started!\n";
211 static int count = 0;
213 if (count == 1 && _main_thread ==
nullptr) {
224 init_external_thread() {
225 if (_external_thread ==
nullptr) {
228 _external_thread->
ref();
The special "external thread" class.
The special "main thread" class.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool start(ThreadPriority priority, bool joinable)
Starts the thread executing.
PT(Thread) Thread
Returns a new Panda Thread object associated with the current thread (which has been created external...
void output_blocker(std::ostream &out) const
Writes a description of the mutex or condition variable that this thread is blocked on.
virtual ~PStatsCallback()
Since this class is just an interface definition, there is no need to have a destructor.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
set_pipeline_stage
Specifies the Pipeline stage number associated with this thread.
get_current_thread
Returns a pointer to the currently-executing Thread object.
TypeHandle is the identifier used to differentiate C++ class types.
virtual void activate_hook(Thread *thread)
Called when the thread is activated (resumes execution).
virtual void deactivate_hook(Thread *thread)
Called when the thread is deactivated (swapped for another running thread).
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void ref() const
Explicitly increments the reference count.
A base class for all things which can have a name.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
get_sync_name
Returns the sync name of the thread.
get_external_thread
Returns a pointer to the "external" Thread object–this is a special Thread object that corresponds to...
A thread; that is, a lightweight process.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.