diff --git a/makepanda/makepanda.vcproj b/makepanda/makepanda.vcproj index 785061eea8..a1b720bfde 100644 --- a/makepanda/makepanda.vcproj +++ b/makepanda/makepanda.vcproj @@ -2147,7 +2147,6 @@ - @@ -2174,7 +2173,6 @@ - @@ -2215,7 +2213,6 @@ - @@ -2259,7 +2256,6 @@ - @@ -2286,7 +2282,6 @@ - @@ -2294,7 +2289,6 @@ - diff --git a/panda/src/express/p3express_composite2.cxx b/panda/src/express/p3express_composite2.cxx index 5caa03986d..29b1da723e 100644 --- a/panda/src/express/p3express_composite2.cxx +++ b/panda/src/express/p3express_composite2.cxx @@ -8,8 +8,6 @@ #include "subStream.cxx" #include "subStreamBuf.cxx" #include "temporaryFile.cxx" -#include "threadSafePointerTo.cxx" -#include "threadSafePointerToBase.cxx" #include "trueClock.cxx" #include "typedReferenceCount.cxx" #include "virtualFile.cxx" diff --git a/panda/src/express/threadSafePointerTo.I b/panda/src/express/threadSafePointerTo.I deleted file mode 100644 index ef2b8db410..0000000000 --- a/panda/src/express/threadSafePointerTo.I +++ /dev/null @@ -1,207 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file threadSafePointerTo.I - * @author drose - * @date 2006-04-28 - */ - -/** - * - */ -template -INLINE ThreadSafePointerTo:: -ThreadSafePointerTo(To *ptr) : ThreadSafePointerToBase(ptr) { -} - -/** - * - */ -template -INLINE ThreadSafePointerTo:: -ThreadSafePointerTo(const ThreadSafePointerTo ©) : - ThreadSafePointerToBase((const ThreadSafePointerToBase &)copy) -{ -} - -/** - * - */ -template -INLINE ThreadSafePointerTo:: -~ThreadSafePointerTo() { -} - -/** - * - */ -template -INLINE typename ThreadSafePointerTo::To &ThreadSafePointerTo:: -operator *() const { - return *((To *)AtomicAdjust::get_ptr(this->_void_ptr)); -} - -/** - * - */ -template -INLINE typename ThreadSafePointerTo::To *ThreadSafePointerTo:: -operator -> () const { - return (To *)AtomicAdjust::get_ptr(this->_void_ptr); -} - -/** - * We also have the typecast operator to automatically convert - * ThreadSafePointerTo's to the required kind of actual pointer. This - * introduces ambiguities which the compiler will resolve one way or the - * other, but we don't care which way it goes because either will be correct. - */ -template -INLINE ThreadSafePointerTo:: -operator T * () const { - return (To *)AtomicAdjust::get_ptr(this->_void_ptr); -} - -/** - * Returns an ordinary pointer instead of a ThreadSafePointerTo. Useful to - * work around compiler problems, particularly for implicit upcasts. - */ -template -INLINE typename ThreadSafePointerTo::To *ThreadSafePointerTo:: -p() const { - return (To *)AtomicAdjust::get_ptr(this->_void_ptr); -} - -/** - * - */ -template -INLINE ThreadSafePointerTo &ThreadSafePointerTo:: -operator = (To *ptr) { - this->reassign(ptr); - return *this; -} - -/** - * - */ -template -INLINE ThreadSafePointerTo &ThreadSafePointerTo:: -operator = (const ThreadSafePointerTo ©) { - this->reassign((const ThreadSafePointerToBase &)copy); - return *this; -} - -/** - * - */ -template -INLINE ThreadSafeConstPointerTo:: -ThreadSafeConstPointerTo(const typename ThreadSafeConstPointerTo::To *ptr) : - ThreadSafePointerToBase((typename ThreadSafeConstPointerTo::To *)ptr) -{ -} - -/** - * - */ -template -INLINE ThreadSafeConstPointerTo:: -ThreadSafeConstPointerTo(const ThreadSafePointerTo ©) : - ThreadSafePointerToBase((const ThreadSafePointerToBase &)copy) -{ -} - -/** - * - */ -template -INLINE ThreadSafeConstPointerTo:: -~ThreadSafeConstPointerTo() { -} - -/** - * - */ -template -INLINE ThreadSafeConstPointerTo:: -ThreadSafeConstPointerTo(const ThreadSafeConstPointerTo ©) : - ThreadSafePointerToBase((const ThreadSafePointerToBase &)copy) -{ -} - -/** - * - */ -template -INLINE const typename ThreadSafeConstPointerTo::To &ThreadSafeConstPointerTo:: -operator *() const { - return *((To *)AtomicAdjust::get_ptr(this->_void_ptr)); -} - -/** - * - */ -template -INLINE const typename ThreadSafeConstPointerTo::To *ThreadSafeConstPointerTo:: -operator -> () const { - return (To *)AtomicAdjust::get_ptr(this->_void_ptr); -} - -/** - * We also have the typecast operator to automatically convert - * ThreadSafeConstPointerTo's to the required kind of actual pointer. This - * introduces ambiguities which the compiler will resolve one way or the - * other, but we don't care which way it goes because either will be correct. - */ - -template -INLINE ThreadSafeConstPointerTo:: -operator const T * () const { - return (To *)AtomicAdjust::get_ptr(this->_void_ptr); -} - -/** - * Returns an ordinary pointer instead of a ThreadSafeConstPointerTo. Useful - * to work around compiler problems, particularly for implicit upcasts. - */ -template -INLINE const typename ThreadSafeConstPointerTo::To *ThreadSafeConstPointerTo:: -p() const { - return (To *)AtomicAdjust::get_ptr(this->_void_ptr); -} - -/** - * - */ -template -INLINE ThreadSafeConstPointerTo &ThreadSafeConstPointerTo:: -operator = (const To *ptr) { - this->reassign((To *)ptr); - return *this; -} - -/** - * - */ -template -INLINE ThreadSafeConstPointerTo &ThreadSafeConstPointerTo:: -operator = (const ThreadSafePointerTo ©) { - this->reassign((const ThreadSafePointerToBase &)copy); - return *this; -} - -/** - * - */ -template -INLINE ThreadSafeConstPointerTo &ThreadSafeConstPointerTo:: -operator = (const ThreadSafeConstPointerTo ©) { - this->reassign((const ThreadSafePointerToBase &)copy); - return *this; -} diff --git a/panda/src/express/threadSafePointerTo.cxx b/panda/src/express/threadSafePointerTo.cxx deleted file mode 100644 index 4c3692d32e..0000000000 --- a/panda/src/express/threadSafePointerTo.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file threadSafePointerTo.cxx - * @author drose - * @date 2006-04-28 - */ - -#include "threadSafePointerTo.h" diff --git a/panda/src/express/threadSafePointerTo.h b/panda/src/express/threadSafePointerTo.h deleted file mode 100644 index 88699fa23a..0000000000 --- a/panda/src/express/threadSafePointerTo.h +++ /dev/null @@ -1,105 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file threadSafePointerTo.h - * @author drose - * @date 2006-04-28 - */ - -#ifndef THREADSAFEPOINTERTO_H -#define THREADSAFEPOINTERTO_H - -#include "pandabase.h" -#include "threadSafePointerToBase.h" - -/** - * This works exactly like PointerTo, except that the object is designed to be - * thread-safe: it is generally safe to make unprotected assignments to this - * pointer, in the sense that the last assignment will win and the reference - * counts will be properly maintained. - */ -template -class ThreadSafePointerTo : public ThreadSafePointerToBase { -public: - typedef typename ThreadSafePointerToBase::To To; -PUBLISHED: - INLINE ThreadSafePointerTo(To *ptr = nullptr); - INLINE ThreadSafePointerTo(const ThreadSafePointerTo ©); - INLINE ~ThreadSafePointerTo(); - -public: - INLINE To &operator *() const; - INLINE To *operator -> () const; - // MSVC.NET 2005 insists that we use T *, and not To *, here. - INLINE operator T *() const; - -PUBLISHED: - // When downcasting to a derived class from a - // ThreadSafePointerTo, C++ would normally require you to cast - // twice: once to an actual BaseClass pointer, and then again to your - // desired pointer. You can use the handy function p() to avoid this first - // cast and make your code look a bit cleaner. - - // e.g. instead of (MyType *)(BaseClass *)ptr, use (MyType *)ptr.p() - - // If your base class is a derivative of TypedObject, you might want to use - // the DCAST macro defined in typedObject.h instead, e.g. DCAST(MyType, - // ptr). This provides a clean downcast that doesn't require .p() or any - // double-casting, and it can be run-time checked for correctness. - INLINE To *p() const; - - INLINE ThreadSafePointerTo &operator = (To *ptr); - INLINE ThreadSafePointerTo &operator = (const ThreadSafePointerTo ©); - - // These functions normally wouldn't need to be redefined here, but we do so - // anyway just to help out interrogate (which doesn't seem to want to - // automatically export the ThreadSafePointerToBase class). When this works - // again in interrogate, we can remove these. - INLINE bool is_null() const { return ThreadSafePointerToBase::is_null(); } - INLINE void clear() { ThreadSafePointerToBase::clear(); } -}; - - -/** - * - */ -template -class ThreadSafeConstPointerTo : public ThreadSafePointerToBase { -public: - typedef typename ThreadSafePointerToBase::To To; -PUBLISHED: - INLINE ThreadSafeConstPointerTo(const To *ptr = nullptr); - INLINE ThreadSafeConstPointerTo(const ThreadSafePointerTo ©); - INLINE ThreadSafeConstPointerTo(const ThreadSafeConstPointerTo ©); - INLINE ~ThreadSafeConstPointerTo(); - -public: - INLINE const To &operator *() const; - INLINE const To *operator -> () const; - INLINE operator const T *() const; - -PUBLISHED: - INLINE const To *p() const; - - INLINE ThreadSafeConstPointerTo &operator = (const To *ptr); - INLINE ThreadSafeConstPointerTo &operator = (const ThreadSafePointerTo ©); - INLINE ThreadSafeConstPointerTo &operator = (const ThreadSafeConstPointerTo ©); - - // This functions normally wouldn't need to be redefined here, but we do so - // anyway just to help out interrogate (which doesn't seem to want to - // automatically export the ThreadSafePointerToBase class). When this works - // again in interrogate, we can remove this. - INLINE void clear() { ThreadSafePointerToBase::clear(); } -}; - -#define TSPT(type) ThreadSafePointerTo< type > -#define TSCPT(type) ThreadSafeConstPointerTo< type > - -#include "threadSafePointerTo.I" - -#endif diff --git a/panda/src/express/threadSafePointerToBase.I b/panda/src/express/threadSafePointerToBase.I deleted file mode 100644 index bee16180b1..0000000000 --- a/panda/src/express/threadSafePointerToBase.I +++ /dev/null @@ -1,132 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file threadSafePointerToBase.I - * @author drose - * @date 2006-04-28 - */ - -/** - * - */ -template -INLINE ThreadSafePointerToBase:: -ThreadSafePointerToBase(To *ptr) { - reassign(ptr); -} - -/** - * - */ -template -INLINE ThreadSafePointerToBase:: -ThreadSafePointerToBase(const ThreadSafePointerToBase ©) { - reassign(copy); -} - -/** - * - */ -template -INLINE ThreadSafePointerToBase:: -~ThreadSafePointerToBase() { - reassign(nullptr); -} - -/** - * This is the main work of the ThreadSafePointerTo family. When the pointer - * is reassigned, decrement the old reference count and increment the new one. - */ -template -INLINE void ThreadSafePointerToBase:: -reassign(To *ptr) { - To *old_ptr = (To *)AtomicAdjust::get_ptr(_void_ptr); - if (ptr == old_ptr) { - return; - } - -#ifdef HAVE_THREADS - void *orig_ptr = AtomicAdjust::compare_and_exchange_ptr(_void_ptr, old_ptr, ptr); - while (orig_ptr != old_ptr) { - // Some other thread assigned it first. Try again. - old_ptr = (To *)AtomicAdjust::get_ptr(_void_ptr); - if (ptr == old_ptr) { - return; - } - - orig_ptr = AtomicAdjust::compare_and_exchange_ptr(_void_ptr, old_ptr, ptr); - } -#else // HAVE_THREADS - _void_ptr = ptr; -#endif // HAVE_THREADS - - if (ptr != nullptr) { - ptr->ref(); -#ifdef DO_MEMORY_USAGE - if (MemoryUsage::get_track_memory_usage()) { - update_type(ptr); - } -#endif - } - - // Now delete the old pointer. - if (old_ptr != nullptr) { - unref_delete(old_ptr); - } -} - -/** - * - */ -template -INLINE void ThreadSafePointerToBase:: -reassign(const ThreadSafePointerToBase ©) { - reassign((To *)copy._void_ptr); -} - -/** - * Ensures that the MemoryUsage record for the pointer has the right type of - * object, if we know the type ourselves. - */ -template -void ThreadSafePointerToBase:: -update_type(To *ptr) { -#ifdef DO_MEMORY_USAGE - TypeHandle type = get_type_handle(To); - if (type == TypeHandle::none()) { - do_init_type(To); - type = get_type_handle(To); - } - if (type != TypeHandle::none()) { - MemoryUsage::update_type(ptr, type); - } -#endif // DO_MEMORY_USAGE -} - -/** - * A convenient way to set the ThreadSafePointerTo object to NULL. (Assignment - * to a NULL pointer also works, of course.) - */ -template -INLINE void ThreadSafePointerToBase:: -clear() { - reassign(nullptr); -} - -/** - * A handy function to output ThreadSafePointerTo's as a hex pointer followed - * by a reference count. - */ -template -INLINE void ThreadSafePointerToBase:: -output(std::ostream &out) const { - out << _void_ptr; - if (_void_ptr != nullptr) { - out << ":" << ((To *)_void_ptr)->get_ref_count(); - } -} diff --git a/panda/src/express/threadSafePointerToBase.cxx b/panda/src/express/threadSafePointerToBase.cxx deleted file mode 100644 index 20d0230c86..0000000000 --- a/panda/src/express/threadSafePointerToBase.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file threadSafePointerToBase.cxx - * @author drose - * @date 2006-04-28 - */ - -#include "threadSafePointerToBase.h" diff --git a/panda/src/express/threadSafePointerToBase.h b/panda/src/express/threadSafePointerToBase.h deleted file mode 100644 index 764e538d2b..0000000000 --- a/panda/src/express/threadSafePointerToBase.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - * PANDA 3D SOFTWARE - * Copyright (c) Carnegie Mellon University. All rights reserved. - * - * All use of this software is subject to the terms of the revised BSD - * license. You should have received a copy of this license along - * with this source code in a file named "LICENSE." - * - * @file threadSafePointerToBase.h - * @author drose - * @date 2006-04-28 - */ - -#ifndef THREADSAFEPOINTERTOBASE_H -#define THREADSAFEPOINTERTOBASE_H - -#include "pandabase.h" -#include "pointerToVoid.h" -#include "referenceCount.h" -#include "typedef.h" -#include "memoryUsage.h" -#include "config_express.h" -#include "atomicAdjust.h" - -/** - * This is the base class for ThreadSafePointerTo and - * ThreadSafeConstPointerTo. Don't try to use it directly; use either derived - * class instead. - */ -template -class ThreadSafePointerToBase : public PointerToVoid { -public: - typedef T To; - -protected: - INLINE ThreadSafePointerToBase(To *ptr); - INLINE ThreadSafePointerToBase(const ThreadSafePointerToBase ©); - INLINE ~ThreadSafePointerToBase(); - - INLINE void reassign(To *ptr); - INLINE void reassign(const ThreadSafePointerToBase ©); - - void update_type(To *ptr); - - // No assignment or retrieval functions are declared in - // ThreadSafePointerToBase, because we will have to specialize on const vs. - // non-const later. - -PUBLISHED: - INLINE void clear(); - - void output(std::ostream &out) const; -}; - -template -INLINE std::ostream &operator <<(std::ostream &out, const ThreadSafePointerToBase &pointer) { - pointer.output(out); - return out; -} - -#include "threadSafePointerToBase.I" - -#endif