diff --git a/panda/src/pipeline/thread.I b/panda/src/pipeline/thread.I index f94be2d225..fd503c68e5 100644 --- a/panda/src/pipeline/thread.I +++ b/panda/src/pipeline/thread.I @@ -205,6 +205,26 @@ is_true_threads() { return ThreadImpl::is_true_threads(); } +//////////////////////////////////////////////////////////////////// +// Function: Thread::is_simple_threads +// Access: Published, Static +// Description: Returns true if Panda is currently compiled for +// "simple threads", which is to say, cooperative +// context switching only, reducing the need for quite +// so many critical section protections. This is not +// necessarily the opposite of "true threads", since one +// possible implementation of simple threads is via true +// threads with mutex protection to ensure only one runs +// at a time. +//////////////////////////////////////////////////////////////////// +INLINE bool Thread:: +is_simple_threads() { + if (!support_threads) { + return false; + } + return ThreadImpl::is_simple_threads(); +} + //////////////////////////////////////////////////////////////////// // Function: Thread::sleep // Access: Published, Static diff --git a/panda/src/pipeline/thread.h b/panda/src/pipeline/thread.h index 77f85bae9a..530912d05c 100644 --- a/panda/src/pipeline/thread.h +++ b/panda/src/pipeline/thread.h @@ -80,6 +80,7 @@ PUBLISHED: INLINE static int get_current_pipeline_stage(); INLINE static bool is_threading_supported(); INLINE static bool is_true_threads(); + INLINE static bool is_simple_threads(); BLOCKING INLINE static void sleep(double seconds); BLOCKING INLINE static void force_yield(); diff --git a/panda/src/pipeline/threadDummyImpl.I b/panda/src/pipeline/threadDummyImpl.I index 4ae3cf50c3..9e19e9b0ba 100644 --- a/panda/src/pipeline/threadDummyImpl.I +++ b/panda/src/pipeline/threadDummyImpl.I @@ -112,6 +112,16 @@ is_true_threads() { return false; } +//////////////////////////////////////////////////////////////////// +// Function: ThreadDummyImpl::is_simple_threads +// Access: Public, Static +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool ThreadDummyImpl:: +is_simple_threads() { + return false; +} + //////////////////////////////////////////////////////////////////// // Function: ThreadDummyImpl::sleep // Access: Public, Static diff --git a/panda/src/pipeline/threadDummyImpl.h b/panda/src/pipeline/threadDummyImpl.h index 4b7b19c954..4084f2f181 100644 --- a/panda/src/pipeline/threadDummyImpl.h +++ b/panda/src/pipeline/threadDummyImpl.h @@ -54,6 +54,7 @@ public: INLINE static void bind_thread(Thread *thread); INLINE static bool is_threading_supported(); INLINE static bool is_true_threads(); + INLINE static bool is_simple_threads(); INLINE static void sleep(double seconds); INLINE static void yield(); INLINE static void consider_yield(); diff --git a/panda/src/pipeline/threadPosixImpl.I b/panda/src/pipeline/threadPosixImpl.I index c82c22dd04..059f0ffbe0 100644 --- a/panda/src/pipeline/threadPosixImpl.I +++ b/panda/src/pipeline/threadPosixImpl.I @@ -95,6 +95,16 @@ is_true_threads() { return true; } +//////////////////////////////////////////////////////////////////// +// Function: ThreadPosixImpl::is_simple_threads +// Access: Public, Static +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool ThreadPosixImpl:: +is_simple_threads() { + return false; +} + //////////////////////////////////////////////////////////////////// // Function: ThreadPosixImpl::sleep // Access: Public, Static diff --git a/panda/src/pipeline/threadPosixImpl.h b/panda/src/pipeline/threadPosixImpl.h index 7fedf46406..e325dd6cd8 100644 --- a/panda/src/pipeline/threadPosixImpl.h +++ b/panda/src/pipeline/threadPosixImpl.h @@ -50,6 +50,7 @@ public: INLINE static void bind_thread(Thread *thread); INLINE static bool is_threading_supported(); INLINE static bool is_true_threads(); + INLINE static bool is_simple_threads(); INLINE static void sleep(double seconds); INLINE static void yield(); INLINE static void consider_yield(); diff --git a/panda/src/pipeline/threadSimpleImpl.I b/panda/src/pipeline/threadSimpleImpl.I index 47a88580a6..ef2950ac23 100644 --- a/panda/src/pipeline/threadSimpleImpl.I +++ b/panda/src/pipeline/threadSimpleImpl.I @@ -72,6 +72,16 @@ is_true_threads() { return (is_os_threads != 0); } +//////////////////////////////////////////////////////////////////// +// Function: ThreadSimpleImpl::is_simple_threads +// Access: Public, Static +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool ThreadSimpleImpl:: +is_simple_threads() { + return true; +} + //////////////////////////////////////////////////////////////////// // Function: ThreadSimpleImpl::sleep // Access: Public, Static diff --git a/panda/src/pipeline/threadSimpleImpl.h b/panda/src/pipeline/threadSimpleImpl.h index 1f0203d99e..5d7f5e0f13 100644 --- a/panda/src/pipeline/threadSimpleImpl.h +++ b/panda/src/pipeline/threadSimpleImpl.h @@ -78,6 +78,7 @@ public: INLINE static void bind_thread(Thread *thread); INLINE static bool is_threading_supported(); INLINE static bool is_true_threads(); + INLINE static bool is_simple_threads(); INLINE static void sleep(double seconds); INLINE static void yield(); INLINE static void consider_yield(); diff --git a/panda/src/pipeline/threadWin32Impl.I b/panda/src/pipeline/threadWin32Impl.I index d69915defb..988a2830e6 100644 --- a/panda/src/pipeline/threadWin32Impl.I +++ b/panda/src/pipeline/threadWin32Impl.I @@ -95,6 +95,16 @@ is_true_threads() { return true; } +//////////////////////////////////////////////////////////////////// +// Function: ThreadWin32Impl::is_simple_threads +// Access: Public, Static +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool ThreadWin32Impl:: +is_simple_threads() { + return false; +} + //////////////////////////////////////////////////////////////////// // Function: ThreadWin32Impl::sleep // Access: Public, Static diff --git a/panda/src/pipeline/threadWin32Impl.h b/panda/src/pipeline/threadWin32Impl.h index 73c71e364c..3957677b5a 100644 --- a/panda/src/pipeline/threadWin32Impl.h +++ b/panda/src/pipeline/threadWin32Impl.h @@ -49,6 +49,7 @@ public: INLINE static void bind_thread(Thread *thread); INLINE static bool is_threading_supported(); INLINE static bool is_true_threads(); + INLINE static bool is_simple_threads(); INLINE static void sleep(double seconds); INLINE static void yield(); INLINE static void consider_yield();