diff --git a/panda/src/putil/copyOnWritePointer.I b/panda/src/putil/copyOnWritePointer.I index ae7ab4403b..a4dceb8e3d 100644 --- a/panda/src/putil/copyOnWritePointer.I +++ b/panda/src/putil/copyOnWritePointer.I @@ -85,7 +85,7 @@ INLINE CopyOnWritePointer:: } } -#ifndef HAVE_THREADS +#ifndef COW_THREADED //////////////////////////////////////////////////////////////////// // Function: CopyOnWritePointer::get_read_pointer // Access: Public @@ -100,9 +100,9 @@ INLINE const CopyOnWriteObject *CopyOnWritePointer:: get_read_pointer() const { return _object; } -#endif // HAVE_THREADS +#endif // COW_THREADED -#ifndef HAVE_THREADS +#ifndef COW_THREADED //////////////////////////////////////////////////////////////////// // Function: CopyOnWritePointer::get_write_pointer // Access: Public @@ -129,7 +129,7 @@ get_write_pointer() { } return _object; } -#endif // HAVE_THREADS +#endif // COW_THREADED //////////////////////////////////////////////////////////////////// // Function: CopyOnWritePointer::get_unsafe_pointer @@ -247,7 +247,7 @@ operator = (To *object) { #endif // CPPPARSER #ifndef CPPPARSER -#ifdef HAVE_THREADS +#ifdef COW_THREADED //////////////////////////////////////////////////////////////////// // Function: CopyOnWritePointerTo::get_read_pointer // Access: Public @@ -258,7 +258,7 @@ INLINE CPT(TYPENAME CopyOnWritePointerTo::To) CopyOnWritePointerTo:: get_read_pointer() const { return (const To *)(CopyOnWritePointer::get_read_pointer().p()); } -#else // HAVE_THREADS +#else // COW_THREADED //////////////////////////////////////////////////////////////////// // Function: CopyOnWritePointerTo::get_read_pointer // Access: Public @@ -269,11 +269,11 @@ INLINE const TYPENAME CopyOnWritePointerTo::To *CopyOnWritePointerTo:: get_read_pointer() const { return (const To *)CopyOnWritePointer::get_read_pointer(); } -#endif // HAVE_THREADS +#endif // COW_THREADED #endif // CPPPARSER #ifndef CPPPARSER -#ifdef HAVE_THREADS +#ifdef COW_THREADED //////////////////////////////////////////////////////////////////// // Function: CopyOnWritePointerTo::get_write_pointer // Access: Public @@ -284,7 +284,7 @@ INLINE PT(TYPENAME CopyOnWritePointerTo::To) CopyOnWritePointerTo:: get_write_pointer() { return (To *)(CopyOnWritePointer::get_write_pointer().p()); } -#else // HAVE_THREADS +#else // COW_THREADED //////////////////////////////////////////////////////////////////// // Function: CopyOnWritePointerTo::get_write_pointer // Access: Public @@ -295,7 +295,7 @@ INLINE TYPENAME CopyOnWritePointerTo::To *CopyOnWritePointerTo:: get_write_pointer() { return (To *)CopyOnWritePointer::get_write_pointer(); } -#endif // HAVE_THREADS +#endif // COW_THREADED #endif // CPPPARSER #ifndef CPPPARSER diff --git a/panda/src/putil/copyOnWritePointer.cxx b/panda/src/putil/copyOnWritePointer.cxx index e6980d6d90..52009ec079 100644 --- a/panda/src/putil/copyOnWritePointer.cxx +++ b/panda/src/putil/copyOnWritePointer.cxx @@ -21,7 +21,7 @@ #include "config_util.h" #include "config_pipeline.h" -#ifdef HAVE_THREADS +#ifdef COW_THREADED //////////////////////////////////////////////////////////////////// // Function: CopyOnWritePointer::get_read_pointer // Access: Public @@ -52,9 +52,9 @@ get_read_pointer() const { _object->_locking_thread = Thread::get_current_thread(); return _object; } -#endif // HAVE_THREADS +#endif // COW_THREADED -#ifdef HAVE_THREADS +#ifdef COW_THREADED //////////////////////////////////////////////////////////////////// // Function: CopyOnWritePointer::get_write_pointer // Access: Public @@ -125,4 +125,4 @@ get_write_pointer() { return _object; } -#endif // HAVE_THREADS +#endif // COW_THREADED diff --git a/panda/src/putil/copyOnWritePointer.h b/panda/src/putil/copyOnWritePointer.h index 1c0ca00749..39a794e853 100644 --- a/panda/src/putil/copyOnWritePointer.h +++ b/panda/src/putil/copyOnWritePointer.h @@ -25,6 +25,15 @@ #include "pointerTo.h" #include "dcast.h" +// Should we implement full thread protection for CopyOnWritePointer? +// If we can be assured that no other thread will interrupt while a +// write pointer is held, we don't need thread protection. +#if defined(HAVE_THREADS) && !(defined(SIMPLE_THREADS) && defined(SIMPLE_THREADS_NO_IMPLICIT_YIELD)) + #define COW_THREADED 1 +#else + #undef COW_THREADED +#endif + //////////////////////////////////////////////////////////////////// // Class : CopyOnWritePointer // Description : This safely stores the primary, owned pointer to a @@ -44,13 +53,13 @@ public: INLINE void operator = (CopyOnWriteObject *object); INLINE ~CopyOnWritePointer(); -#ifdef HAVE_THREADS +#ifdef COW_THREADED CPT(CopyOnWriteObject) get_read_pointer() const; PT(CopyOnWriteObject) get_write_pointer(); #else INLINE const CopyOnWriteObject *get_read_pointer() const; INLINE CopyOnWriteObject *get_write_pointer(); -#endif // HAVE_THREADS +#endif // COW_THREADED INLINE CopyOnWriteObject *get_unsafe_pointer(); @@ -83,13 +92,13 @@ public: INLINE void operator = (const CopyOnWritePointerTo ©); INLINE void operator = (To *object); -#ifdef HAVE_THREADS +#ifdef COW_THREADED INLINE CPT(To) get_read_pointer() const; INLINE PT(To) get_write_pointer(); #else INLINE const To *get_read_pointer() const; INLINE To *get_write_pointer(); -#endif // HAVE_THREADS +#endif // COW_THREADED INLINE To *get_unsafe_pointer(); #endif // CPPPARSER