Panda3D
 All Classes Functions Variables Enumerations
pipelineCyclerLinks.I
00001 // Filename: pipelineCyclerLinks.I
00002 // Created by:  drose (16Feb06)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 #ifdef THREADED_PIPELINE
00017 ////////////////////////////////////////////////////////////////////
00018 //     Function: PipelineCyclerLinks::Constructor
00019 //       Access: Protected
00020 //  Description: 
00021 ////////////////////////////////////////////////////////////////////
00022 INLINE PipelineCyclerLinks::
00023 PipelineCyclerLinks() {
00024 #ifndef NDEBUG
00025   _next = NULL;
00026   _prev = NULL;
00027 #endif
00028 }
00029 #endif  // THREADED_PIPELINE
00030 
00031 #ifdef THREADED_PIPELINE
00032 ////////////////////////////////////////////////////////////////////
00033 //     Function: PipelineCyclerLinks::Destructor
00034 //       Access: Protected
00035 //  Description: 
00036 ////////////////////////////////////////////////////////////////////
00037 INLINE PipelineCyclerLinks::
00038 ~PipelineCyclerLinks() {
00039   nassertv(_next == NULL && _prev == NULL);
00040 }
00041 #endif  // THREADED_PIPELINE
00042 
00043 #ifdef THREADED_PIPELINE
00044 ////////////////////////////////////////////////////////////////////
00045 //     Function: PipelineCyclerLinks::make_head
00046 //       Access: Protected
00047 //  Description: When called on an empty object, sets it up to be the
00048 //               head of a linked list.
00049 ////////////////////////////////////////////////////////////////////
00050 INLINE void PipelineCyclerLinks::
00051 make_head() {
00052   nassertv(_next == NULL && _prev == NULL);
00053   _next = this;
00054   _prev = this;
00055 }
00056 #endif  // THREADED_PIPELINE
00057 
00058 #ifdef THREADED_PIPELINE
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: PipelineCyclerLinks::clear_head
00061 //       Access: Protected
00062 //  Description: When called on the head of an empty linked list,
00063 //               resets it to an empty object, for safe destruction.
00064 ////////////////////////////////////////////////////////////////////
00065 INLINE void PipelineCyclerLinks::
00066 clear_head() {
00067   nassertv(_next == this && _prev == this);
00068 #ifndef NDEBUG
00069   _next = NULL;
00070   _prev = NULL;
00071 #endif
00072 }
00073 #endif  // THREADED_PIPELINE
00074 
00075 #ifdef THREADED_PIPELINE
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function: PipelineCyclerLinks::remove_from_list
00078 //       Access: Protected
00079 //  Description: Removes a PipelineCyclerLinks record from the
00080 //               doubly-linked list.
00081 ////////////////////////////////////////////////////////////////////
00082 INLINE void PipelineCyclerLinks::
00083 remove_from_list() {
00084   nassertv(_prev->_next == this && _next->_prev == this);
00085   _prev->_next = _next;
00086   _next->_prev = _prev;
00087 #ifndef NDEBUG
00088   _next = NULL;
00089   _prev = NULL;
00090 #endif
00091 }
00092 #endif  // THREADED_PIPELINE
00093 
00094 #ifdef THREADED_PIPELINE
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function: PipelineCyclerLinks::insert_before
00097 //       Access: Protected
00098 //  Description: Adds a PipelineCyclerLinks record before the indicated
00099 //               node in the doubly-linked list.
00100 ////////////////////////////////////////////////////////////////////
00101 INLINE void PipelineCyclerLinks::
00102 insert_before(PipelineCyclerLinks *node) {
00103   nassertv(node->_prev->_next == node && node->_next->_prev == node);
00104   nassertv(_prev == (PipelineCyclerLinks *)NULL &&
00105            _next == (PipelineCyclerLinks *)NULL);
00106   _prev = node->_prev;
00107   _next = node;
00108   _prev->_next = this;
00109   node->_prev = this;
00110 }
00111 #endif  // THREADED_PIPELINE
00112 
00113 #ifdef THREADED_PIPELINE
00114 ////////////////////////////////////////////////////////////////////
00115 //     Function: PipelineCyclerLinks::take_list
00116 //       Access: Protected
00117 //  Description: When called on the head of an empty list, takes all
00118 //               of the leemnts from the indicated list and moves them
00119 //               to this list.
00120 ////////////////////////////////////////////////////////////////////
00121 INLINE void PipelineCyclerLinks::
00122 take_list(PipelineCyclerLinks &other) {
00123   nassertv(_next == this && _prev == this);
00124   if (other._next == &other && other._prev == &other) {
00125     // The other list is empty; this is a no-op.
00126     return;
00127   }
00128 
00129   other._next->_prev = this;
00130   other._prev->_next = this;
00131   _next = other._next;
00132   _prev = other._prev;
00133 
00134   other._next = &other;
00135   other._prev = &other;
00136 }
00137 #endif  // THREADED_PIPELINE
 All Classes Functions Variables Enumerations