mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
is_true_threads(), write_status()
This commit is contained in:
parent
f90469bbfe
commit
26306d6e3e
@ -226,10 +226,9 @@ get_current_pipeline_stage() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Thread::is_threading_supported
|
||||
// Access: Published, Static
|
||||
// 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).
|
||||
// Description: Returns true if threading support has been compiled
|
||||
// in and enabled, or false if no threading is available
|
||||
// (and Thread::start() will always fail).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool Thread::
|
||||
is_threading_supported() {
|
||||
@ -239,6 +238,22 @@ is_threading_supported() {
|
||||
return ThreadImpl::is_threading_supported();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Thread::is_true_threads
|
||||
// Access: Published, Static
|
||||
// Description: Returns true if a real threading library is available
|
||||
// that supports actual OS-implemented threads, or false
|
||||
// if the only threading we can provide is simulated
|
||||
// user-space threading.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool Thread::
|
||||
is_true_threads() {
|
||||
if (!support_threads) {
|
||||
return false;
|
||||
}
|
||||
return ThreadImpl::is_true_threads();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Thread::sleep
|
||||
// Access: Published, Static
|
||||
|
@ -117,6 +117,18 @@ output(ostream &out) const {
|
||||
out << get_type() << " " << get_name();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Thread::write_status
|
||||
// Access: Published, Static
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void Thread::
|
||||
write_status(ostream &out) {
|
||||
#ifdef SIMPLE_THREADS
|
||||
ThreadImpl::write_status(out);
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Thread::start
|
||||
// Access: Public
|
||||
|
@ -75,12 +75,14 @@ PUBLISHED:
|
||||
INLINE static Thread *get_current_thread();
|
||||
INLINE static int get_current_pipeline_stage();
|
||||
INLINE static bool is_threading_supported();
|
||||
INLINE static bool is_true_threads();
|
||||
BLOCKING INLINE static void sleep(double seconds);
|
||||
|
||||
BLOCKING INLINE static void force_yield();
|
||||
BLOCKING INLINE static void consider_yield();
|
||||
|
||||
virtual void output(ostream &out) const;
|
||||
static void write_status(ostream &out);
|
||||
|
||||
INLINE bool is_started() const;
|
||||
|
||||
|
@ -106,6 +106,16 @@ is_threading_supported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ThreadDummyImpl::is_true_threads
|
||||
// Access: Public, Static
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ThreadDummyImpl::
|
||||
is_true_threads() {
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ThreadDummyImpl::sleep
|
||||
// Access: Public, Static
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
static Thread *get_current_thread();
|
||||
INLINE static void bind_thread(Thread *thread);
|
||||
INLINE static bool is_threading_supported();
|
||||
INLINE static bool is_true_threads();
|
||||
INLINE static void sleep(double seconds);
|
||||
INLINE static void yield();
|
||||
INLINE static void consider_yield();
|
||||
|
@ -89,6 +89,16 @@ is_threading_supported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ThreadPosixImpl::is_true_threads
|
||||
// Access: Public, Static
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ThreadPosixImpl::
|
||||
is_true_threads() {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ThreadPosixImpl::sleep
|
||||
// Access: Public, Static
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
INLINE static Thread *get_current_thread();
|
||||
INLINE static void bind_thread(Thread *thread);
|
||||
INLINE static bool is_threading_supported();
|
||||
INLINE static bool is_true_threads();
|
||||
INLINE static void sleep(double seconds);
|
||||
INLINE static void yield();
|
||||
INLINE static void consider_yield();
|
||||
|
@ -48,6 +48,16 @@ is_threading_supported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ThreadSimpleImpl::is_true_threads
|
||||
// Access: Public, Static
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ThreadSimpleImpl::
|
||||
is_true_threads() {
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ThreadSimpleImpl::sleep
|
||||
// Access: Public, Static
|
||||
@ -106,3 +116,14 @@ INLINE double ThreadSimpleImpl::
|
||||
get_start_time() const {
|
||||
return _start_time;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ThreadSimpleImpl::write_status
|
||||
// Access: Public, Static
|
||||
// Description: Writes a list of threads running and threads blocked.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ThreadSimpleImpl::
|
||||
write_status(ostream &out) {
|
||||
ThreadSimpleManager *manager = ThreadSimpleManager::get_global_ptr();
|
||||
manager->write_status(out);
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
INLINE static Thread *get_current_thread();
|
||||
INLINE static void bind_thread(Thread *thread);
|
||||
INLINE static bool is_threading_supported();
|
||||
INLINE static bool is_true_threads();
|
||||
INLINE static void sleep(double seconds);
|
||||
INLINE static void yield();
|
||||
INLINE static void consider_yield();
|
||||
@ -87,6 +88,8 @@ public:
|
||||
|
||||
INLINE double get_start_time() const;
|
||||
|
||||
INLINE static void write_status(ostream &out);
|
||||
|
||||
private:
|
||||
static void st_begin_thread(void *data);
|
||||
void begin_thread();
|
||||
|
@ -254,6 +254,48 @@ set_current_thread(ThreadSimpleImpl *current_thread) {
|
||||
_current_thread = current_thread;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ThreadSimpleManager::write_status
|
||||
// Access: Public
|
||||
// Description: Writes a list of threads running and threads blocked.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void ThreadSimpleManager::
|
||||
write_status(ostream &out) const {
|
||||
out << "Currently running: " << *_current_thread->_parent_obj << "\n";
|
||||
|
||||
out << "Ready:";
|
||||
FifoThreads::const_iterator ti;
|
||||
for (ti = _ready.begin(); ti != _ready.end(); ++ti) {
|
||||
out << " " << *(*ti)->_parent_obj;
|
||||
}
|
||||
out << "\n";
|
||||
|
||||
double now = get_current_time();
|
||||
out << "Sleeping:";
|
||||
// Copy and sort for convenience.
|
||||
Sleeping s2 = _sleeping;
|
||||
sort(s2.begin(), s2.end(), CompareStartTime());
|
||||
Sleeping::const_iterator si;
|
||||
for (si = s2.begin(); si != s2.end(); ++si) {
|
||||
out << " " << *(*si)->_parent_obj << "(" << (*si)->_start_time - now
|
||||
<< "s)";
|
||||
}
|
||||
out << "\n";
|
||||
|
||||
Blocked::const_iterator bi;
|
||||
for (bi = _blocked.begin(); bi != _blocked.end(); ++bi) {
|
||||
BlockerSimple *blocker = (*bi).first;
|
||||
const FifoThreads &threads = (*bi).second;
|
||||
out << "On blocker " << blocker << ":\n";
|
||||
FifoThreads::const_iterator ti;
|
||||
for (ti = threads.begin(); ti != threads.end(); ++ti) {
|
||||
ThreadSimpleImpl *thread = (*ti);
|
||||
out << " " << *thread->_parent_obj;
|
||||
}
|
||||
out << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ThreadSimpleManager::init_pointers
|
||||
// Access: Private, Static
|
||||
|
@ -70,6 +70,8 @@ public:
|
||||
INLINE double get_current_time() const;
|
||||
INLINE static ThreadSimpleManager *get_global_ptr();
|
||||
|
||||
void write_status(ostream &out) const;
|
||||
|
||||
private:
|
||||
static void init_pointers();
|
||||
|
||||
|
@ -89,6 +89,16 @@ is_threading_supported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ThreadWin32Impl::is_true_threads
|
||||
// Access: Public, Static
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ThreadWin32Impl::
|
||||
is_true_threads() {
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ThreadWin32Impl::sleep
|
||||
// Access: Public, Static
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
INLINE static Thread *get_current_thread();
|
||||
INLINE static void bind_thread(Thread *thread);
|
||||
INLINE static bool is_threading_supported();
|
||||
INLINE static bool is_true_threads();
|
||||
INLINE static void sleep(double seconds);
|
||||
INLINE static void yield();
|
||||
INLINE static void consider_yield();
|
||||
|
Loading…
x
Reference in New Issue
Block a user