# ExternalThread

from pandac.PandaModules import ExternalThread

Class : ExternalThread
Description : The special "external thread" class. There is one instance of these in the world, and it is returned by
Thread::get_external_thread().

## Inheritance:

ExternalThread: Thread
Thread: TypedReferenceCount
TypedReferenceCount: TypedObject ReferenceCount
TypedObject:
ReferenceCount:

## Methods of ExternalThread:

getClassType

## Methods of Thread:

bindThread
getClassType
getCurrentPipelineStage
getCurrentThread
getExternalThread
getMainThread
getName
getPipelineStage
getPstatsIndex
getSyncName
isThreadingSupported
output
setMinPipelineStage
setPipelineStage
setPstatsIndex
sleep

## Methods of TypedReferenceCount:

getClassType

## Methods of TypedObject:

getBestParentFromSet
getClassType
getType
getTypeIndex
isExactType
isOfType

## Methods of ReferenceCount:

getClassType
getRefCount
ref
testRefCountIntegrity
unref

getClassType static TypeHandle ExternalThread::get_class_type(void); Undocumented function.

bindThread static PointerTo< Thread > Thread::bind_thread(string const &name, string const &sync_name); Description: Returns a new Panda Thread object associated with the current thread (which has been created externally). This can be used to bind a unique Panda Thread object with an external thread, such as a new Python thread. It is particularly useful to bind a Panda Thread object to an external thread for the purposes of PStats monitoring. Without this call, each external thread will be assigned the same global ExternalThread object, which means they will all appear in the same PStats graph. It is the caller's responsibility to save the returned Thread pointer for the lifetime of the external thread. It is an error for the Thread pointer to destruct while the external thread is still in the system. It is also an error to call this method from the main thread, or twice within a given thread, unless it is given the same name each time (in which case the same pointer will be returned each time).

getClassType static TypeHandle Thread::get_class_type(void); Undocumented function.

getCurrentPipelineStage static int Thread::get_current_pipeline_stage(void); Description: Returns the integer pipeline stage associated with the current thread. This is the same thing as get_current_thread()->get_pipeline_stage(), but it may be faster to retrieve in some contexts.

getCurrentThread static Thread *Thread::get_current_thread(void); Description: Returns a pointer to the currently-executing Thread object. If this is called from the main thread, this will return the same value as get_main_thread(). This will always return some valid Thread pointer. It will never return NULL, even if the current thread was spawned outside of Panda's threading system, although all non-Panda threads will return the exact same Thread pointer.

getExternalThread static Thread *Thread::get_external_thread(void); Description: Returns a pointer to the "external" Thread object--this is a special Thread object that corresponds to any thread spawned outside of Panda's threading interface. Note that multiple different threads may share this same pointer.

getMainThread static Thread *Thread::get_main_thread(void); Description: Returns a pointer to the "main" Thread object--this is the Thread that started the whole process.

getName string const &Thread::get_name(void) const; Description: Returns the name of the thread. Each thread should probably have a unique name, but this is not enforced (and not strictly required).

getPipelineStage int Thread::get_pipeline_stage(void) const; Description: Returns the Pipeline stage number associated with this thread. The default stage is 0 if no stage is specified otherwise. See set_pipeline_stage().

getPstatsIndex int Thread::get_pstats_index(void) const; Description: Returns the PStats index associated with this thread, or -1 if no index has yet been associated with this thread. This is used internally by the PStatClient; you should not need to call this directly.

getSyncName string const &Thread::get_sync_name(void) const; Description: Returns the sync name of the thread. This name collects threads into "sync groups", which are expected to run synchronously. This is mainly used for the benefit of PStats; threads with the same sync name can be ticked all at once via the thread_tick() call.

isThreadingSupported static bool Thread::is_threading_supported(void); Description: Returns true if a real threading library is available that supports threads, or false if no threading library is available (and Thread::start() will always fail).

output virtual void Thread::output(ostream &out) const; Description:

setMinPipelineStage void Thread::set_min_pipeline_stage(int min_pipeline_stage); Description: Sets this thread's pipeline stage number to at least the indicated value, unless it is already larger. See set_pipeline_stage().

setPipelineStage void Thread::set_pipeline_stage(int pipeline_stage); Description: Specifies the Pipeline stage number associated with this thread. The default stage is 0 if no stage is specified otherwise. This must be a value in the range [0 .. pipeline->get_num_stages() - 1]. It specifies the values that this thread observes for all pipelined data. Typically, an application thread will leave this at 0, but a render thread may set it to 1 or 2 (to operate on the previous frame's data, or the second previous frame's data).

setPstatsIndex void Thread::set_pstats_index(int pstats_index); Description: Stores a PStats index to be associated with this thread. This is used internally by the PStatClient; you should not need to call this directly.

sleep static void Thread::sleep(double seconds); Description: Suspends the current thread for at least the indicated amount of time. It might be suspended for longer.

getClassType static TypeHandle TypedReferenceCount::get_class_type(void); Undocumented function.

getBestParentFromSet int TypedObject::get_best_parent_from_Set(set< int > const &) const; Description: Returns true if the current object is the indicated type exactly.

getClassType static TypeHandle TypedObject::get_class_type(void); Undocumented function.

getType virtual TypeHandle TypedObject::get_type(void) const = 0; Derived classes should override this function to return get_class_type().

getTypeIndex int TypedObject::get_type_index(void) const; Description: Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. This is equivalent to get_type().get_index().

isExactType bool TypedObject::is_exact_type(TypeHandle handle) const; Description: Returns true if the current object is the indicated type exactly.

isOfType bool TypedObject::is_of_type(TypeHandle handle) const; Description: Returns true if the current object is or derives from the indicated type.

getClassType static TypeHandle ReferenceCount::get_class_type(void); Undocumented function.

getRefCount int ReferenceCount::get_ref_count(void) const; Description: Returns the current reference count.

ref void ReferenceCount::ref(void) const; Description: Explicitly increments the reference count. User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

testRefCountIntegrity bool ReferenceCount::test_ref_count_integrity(void) const; Description: Does some easy checks to make sure that the reference count isn't completely bogus. Returns true if ok, false otherwise.

unref bool ReferenceCount::unref(void) const; Description: Explicitly decrements the reference count. Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic; plus, we don't have a virtual destructor anyway.) However, see the helper function unref_delete(). User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it. The return value is true if the new reference count is nonzero, false if it is zero.