diff --git a/panda/src/putil/cycleDataReader.I b/panda/src/putil/cycleDataReader.I index cd9b80433d..75ae81c88e 100644 --- a/panda/src/putil/cycleDataReader.I +++ b/panda/src/putil/cycleDataReader.I @@ -16,9 +16,12 @@ // //////////////////////////////////////////////////////////////////// +#ifdef DO_PIPELINING +// This is the implementation for full support of pipelining (as well +// as the sanity-check only implementation). //////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Constructor +// Function: CycleDataReader::Constructor (full) // Access: Public // Description: //////////////////////////////////////////////////////////////////// @@ -32,7 +35,7 @@ CycleDataReader(const PipelineCycler &cycler) : } //////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Copy Constructor +// Function: CycleDataReader::Copy Constructor (full) // Access: Public // Description: //////////////////////////////////////////////////////////////////// @@ -51,7 +54,7 @@ CycleDataReader(const CycleDataReader ©) : } //////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Destructor +// Function: CycleDataReader::Destructor (full) // Access: Public // Description: //////////////////////////////////////////////////////////////////// @@ -69,7 +72,7 @@ INLINE CycleDataReader:: } //////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::operator -> +// Function: CycleDataReader::operator -> (full) // Access: Public // Description: This provides an indirect member access to the actual // CycleData data. @@ -82,7 +85,7 @@ operator -> () const { } //////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::Typecast pointer +// Function: CycleDataReader::Typecast pointer (full) // Access: Public // Description: This allows the CycleDataReader to be passed to any // function that expects a const CycleDataType pointer. @@ -95,7 +98,7 @@ operator const CycleDataType * () const { } //////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::take_pointer +// Function: CycleDataReader::take_pointer (full) // Access: Public // Description: This is intended to be called only from // CycleDataWriter when it elevates the pointer from @@ -115,7 +118,7 @@ take_pointer() { } //////////////////////////////////////////////////////////////////// -// Function: CycleDataReader::elevate_to_write +// Function: CycleDataReader::elevate_to_write (full) // Access: Public // Description: Call this to permanently elevate the readable pointer // to a writable pointer. This returns a writable @@ -132,3 +135,95 @@ elevate_to_write(PipelineCycler &cycler) { } return _write_pointer; } + +#else // !DO_PIPELINING +// This is the trivial, do-nothing implementation. + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataReader::Constructor (trivial) +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE CycleDataReader:: +CycleDataReader(const PipelineCycler &cycler) { + _pointer = cycler.read(); +} + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataReader::Copy Constructor (trivial) +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE CycleDataReader:: +CycleDataReader(const CycleDataReader ©) : + _pointer(copy._pointer) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataReader::Destructor (trivial) +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE CycleDataReader:: +~CycleDataReader() { +} + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataReader::operator -> (trivial) +// Access: Public +// Description: This provides an indirect member access to the actual +// CycleData data. +//////////////////////////////////////////////////////////////////// +template +INLINE const CycleDataType *CycleDataReader:: +operator -> () const { + return _pointer; +} + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataReader::Typecast pointer (trivial) +// Access: Public +// Description: This allows the CycleDataReader to be passed to any +// function that expects a const CycleDataType pointer. +//////////////////////////////////////////////////////////////////// +template +INLINE CycleDataReader:: +operator const CycleDataType * () const { + return _pointer; +} + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataReader::take_pointer (trivial) +// Access: Public +// Description: This is intended to be called only from +// CycleDataWriter when it elevates the pointer from +// read to write status. This function returns the +// reader's pointer and relinquishes ownership of the +// pointer, rendering the reader invalid for future +// reads. +//////////////////////////////////////////////////////////////////// +template +INLINE const CycleDataType *CycleDataReader:: +take_pointer() { + return _pointer; +} + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataReader::elevate_to_write (trivial) +// Access: Public +// Description: Call this to permanently elevate the readable pointer +// to a writable pointer. This returns a writable +// pointer; subsequent calls to the same function will +// trivially return the same writable pointer. +//////////////////////////////////////////////////////////////////// +template +INLINE CycleDataType *CycleDataReader:: +elevate_to_write(PipelineCycler &cycler) { + return (CycleDataType *)_pointer; +} + +#endif // DO_PIPELINING diff --git a/panda/src/putil/cycleDataReader.h b/panda/src/putil/cycleDataReader.h index 62dcf51cc6..c2ec6ea1f8 100644 --- a/panda/src/putil/cycleDataReader.h +++ b/panda/src/putil/cycleDataReader.h @@ -51,9 +51,15 @@ public: INLINE CycleDataType *elevate_to_write(PipelineCycler &cycler); private: +#ifdef DO_PIPELINING + // This is the data stored for a real pipelining implementation. const PipelineCycler &_cycler; const CycleDataType *_pointer; CycleDataType *_write_pointer; +#else // !DO_PIPELINING + // This is all we need for the trivial, do-nothing implementation. + const CycleDataType *_pointer; +#endif // DO_PIPELINING }; #include "cycleDataReader.I" diff --git a/panda/src/putil/cycleDataWriter.I b/panda/src/putil/cycleDataWriter.I index a11429cdfe..36aba39a6c 100644 --- a/panda/src/putil/cycleDataWriter.I +++ b/panda/src/putil/cycleDataWriter.I @@ -16,9 +16,12 @@ // //////////////////////////////////////////////////////////////////// +#ifdef DO_PIPELINING +// This is the implementation for full support of pipelining (as well +// as the sanity-check only implementation). //////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor +// Function: CycleDataWriter::Constructor (full) // Access: Public // Description: //////////////////////////////////////////////////////////////////// @@ -31,7 +34,7 @@ CycleDataWriter(PipelineCycler &cycler) : } //////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor +// Function: CycleDataWriter::Constructor (full) // Access: Public // Description: This is a lot like a copy constructor, in that the // new CycleDataWriter object gets a handle to the same @@ -51,7 +54,7 @@ CycleDataWriter(PipelineCycler &cycler, } //////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Constructor +// Function: CycleDataWriter::Constructor (full) // Access: Public // Description: This flavor of the constructor elevates the pointer // from the CycleDataReader from a read to a write @@ -67,7 +70,7 @@ CycleDataWriter(PipelineCycler &cycler, } //////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Destructor +// Function: CycleDataWriter::Destructor (full) // Access: Public // Description: //////////////////////////////////////////////////////////////////// @@ -80,7 +83,7 @@ INLINE CycleDataWriter:: } //////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::operator -> +// Function: CycleDataWriter::operator -> (full) // Access: Public // Description: This provides an indirect member access to the actual // CycleData data. @@ -93,7 +96,7 @@ operator -> () { } //////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::operator -> +// Function: CycleDataWriter::operator -> (full) // Access: Public // Description: This provides an indirect member access to the actual // CycleData data. @@ -106,7 +109,7 @@ operator -> () const { } //////////////////////////////////////////////////////////////////// -// Function: CycleDataWriter::Typecast pointer +// Function: CycleDataWriter::Typecast pointer (full) // Access: Public // Description: This allows the CycleDataWriter to be passed to any // function that expects a CycleDataType pointer. @@ -117,3 +120,97 @@ operator CycleDataType * () { nassertr(_pointer != (CycleDataType *)NULL, _cycler.cheat()); return _pointer; } + +#else // !DO_PIPELINING +// This is the trivial, do-nothing implementation. + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataWriter::Constructor (trivial) +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE CycleDataWriter:: +CycleDataWriter(PipelineCycler &cycler) { + _pointer = cycler.write(); +} + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataWriter::Constructor (trivial) +// Access: Public +// Description: This is a lot like a copy constructor, in that the +// new CycleDataWriter object gets a handle to the same +// pointer held by the old CycleDataWriter object. +// However, since only one write pointer may be active +// at a time, this invalidates the old object. +//////////////////////////////////////////////////////////////////// +template +INLINE CycleDataWriter:: +CycleDataWriter(PipelineCycler &, + CycleDataWriter &take_from) : + _pointer(take_from.take_pointer()) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataWriter::Constructor (trivial) +// Access: Public +// Description: This flavor of the constructor elevates the pointer +// from the CycleDataReader from a read to a write +// pointer (and invalidates the reader). +//////////////////////////////////////////////////////////////////// +template +INLINE CycleDataWriter:: +CycleDataWriter(PipelineCycler &, + CycleDataReader &take_from) : + _pointer((CycleDataType *)take_from.take_pointer()) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataWriter::Destructor (trivial) +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE CycleDataWriter:: +~CycleDataWriter() { +} + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataWriter::operator -> (trivial) +// Access: Public +// Description: This provides an indirect member access to the actual +// CycleData data. +//////////////////////////////////////////////////////////////////// +template +INLINE CycleDataType *CycleDataWriter:: +operator -> () { + return _pointer; +} + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataWriter::operator -> (trivial) +// Access: Public +// Description: This provides an indirect member access to the actual +// CycleData data. +//////////////////////////////////////////////////////////////////// +template +INLINE const CycleDataType *CycleDataWriter:: +operator -> () const { + return _pointer; +} + +//////////////////////////////////////////////////////////////////// +// Function: CycleDataWriter::Typecast pointer (trivial) +// Access: Public +// Description: This allows the CycleDataWriter to be passed to any +// function that expects a CycleDataType pointer. +//////////////////////////////////////////////////////////////////// +template +INLINE CycleDataWriter:: +operator CycleDataType * () { + return _pointer; +} + +#endif // DO_PIPELINING diff --git a/panda/src/putil/cycleDataWriter.h b/panda/src/putil/cycleDataWriter.h index 5c82a77024..469dc5ac18 100644 --- a/panda/src/putil/cycleDataWriter.h +++ b/panda/src/putil/cycleDataWriter.h @@ -51,8 +51,14 @@ public: INLINE operator CycleDataType * (); private: +#ifdef DO_PIPELINING + // This is the data stored for a real pipelining implementation. PipelineCycler &_cycler; CycleDataType *_pointer; +#else // !DO_PIPELINING + // This is all we need for the trivial, do-nothing implementation. + CycleDataType *_pointer; +#endif // DO_PIPELINING }; #include "cycleDataWriter.I"