51 return _impl.get_unique_id();
60 #if !defined(_DEBUG) && defined(__has_builtin) && __has_builtin(__builtin_assume)
64 int pipeline_stage = _pipeline_stage;
65 __builtin_assume(pipeline_stage >= 0);
66 return pipeline_stage;
68 return _pipeline_stage;
87 if (_main_thread ==
nullptr) {
101 if (_external_thread ==
nullptr) {
102 init_external_thread();
104 return _external_thread;
119 TAU_PROFILE(
"Thread *Thread::get_current_thread()",
" ", TAU_USER);
123 Thread *thread = ThreadImpl::get_current_thread();
124 if (thread ==
nullptr) {
138 TAU_PROFILE(
"int Thread::get_current_pipeline_stage()",
" ", TAU_USER);
139 #ifndef THREADED_PIPELINE
153 if (!support_threads) {
156 return ThreadImpl::is_threading_supported();
166 if (!support_threads) {
169 return ThreadImpl::is_true_threads();
181 if (!support_threads) {
184 return ThreadImpl::is_simple_threads();
192 sleep(
double seconds) {
193 TAU_PROFILE(
"void Thread::sleep(double)",
" ", TAU_USER);
194 ThreadImpl::sleep(seconds);
202 TAU_PROFILE(
"void Thread::yield()",
" ", TAU_USER);
213 TAU_PROFILE(
"void Thread::consider_yield()",
" ", TAU_USER);
214 ThreadImpl::consider_yield();
240 TAU_PROFILE(
"void Thread::join()",
" ", TAU_USER);
275 _python_index = python_index;
284 ThreadImpl::prepare_for_exit();
292 INLINE JNIEnv *Thread::
293 get_jni_env()
const {
294 return _impl.get_jni_env();
304 _pstats_index = pstats_index;
313 _pstats_callback = pstats_callback;
323 return _pstats_callback;
326 INLINE std::ostream &
327 operator << (std::ostream &out,
const Thread &thread) {
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,...
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...
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.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.