COW_THREADED

This commit is contained in:
David Rose 2007-06-22 22:38:09 +00:00
parent 746dde6b94
commit 343d7231f9
3 changed files with 27 additions and 18 deletions

View File

@ -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<T>::To) CopyOnWritePointerTo<T>::
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<T>::To *CopyOnWritePointerTo<T>::
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<T>::To) CopyOnWritePointerTo<T>::
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<T>::To *CopyOnWritePointerTo<T>::
get_write_pointer() {
return (To *)CopyOnWritePointer::get_write_pointer();
}
#endif // HAVE_THREADS
#endif // COW_THREADED
#endif // CPPPARSER
#ifndef CPPPARSER

View File

@ -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

View File

@ -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<T> &copy);
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