Panda3D
 All Classes Functions Variables Enumerations
lightMutexHolder.I
00001 // Filename: lightMutexHolder.I
00002 // Created by:  drose (08Oct08)
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 ////////////////////////////////////////////////////////////////////
00017 //     Function: LightMutexHolder::Constructor
00018 //       Access: Public
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE LightMutexHolder::
00022 LightMutexHolder(const LightMutex &mutex) {
00023 #if defined(HAVE_THREADS) || defined(DEBUG_THREADS)
00024   _mutex = &mutex;
00025   _mutex->acquire();
00026 #endif
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: LightMutexHolder::Constructor
00031 //       Access: Public
00032 //  Description: If the LightMutexHolder constructor is given a pointer to
00033 //               a LightMutex object (instead of an actual object), it will
00034 //               first check to see if the pointer is NULL, and
00035 //               allocate a new LightMutex if it is.  This is intended as a
00036 //               convenience for functions that may need to reference
00037 //               a LightMutex at static init time, when it is impossible to
00038 //               guarantee ordering of initializers.
00039 ////////////////////////////////////////////////////////////////////
00040 INLINE LightMutexHolder::
00041 LightMutexHolder(LightMutex *&mutex) {
00042 #if defined(HAVE_THREADS) || defined(DEBUG_THREADS)
00043   if (mutex == (LightMutex *)NULL) {
00044     mutex = new LightMutex;
00045   }
00046   _mutex = mutex;
00047   _mutex->acquire();
00048 #endif
00049 }
00050 
00051 ////////////////////////////////////////////////////////////////////
00052 //     Function: LightMutexHolder::Destructor
00053 //       Access: Public
00054 //  Description:
00055 ////////////////////////////////////////////////////////////////////
00056 INLINE LightMutexHolder::
00057 ~LightMutexHolder() {
00058 #if defined(HAVE_THREADS) || defined(DEBUG_THREADS)
00059   _mutex->release();
00060 #endif
00061 }
00062 
00063 ////////////////////////////////////////////////////////////////////
00064 //     Function: LightMutexHolder::Copy Constructor
00065 //       Access: Private
00066 //  Description: Do not attempt to copy LightMutexHolders.
00067 ////////////////////////////////////////////////////////////////////
00068 INLINE LightMutexHolder::
00069 LightMutexHolder(const LightMutexHolder &copy) {
00070   nassertv(false);
00071 }
00072 
00073 ////////////////////////////////////////////////////////////////////
00074 //     Function: LightMutexHolder::Copy Assignment Operator
00075 //       Access: Private
00076 //  Description: Do not attempt to copy LightMutexHolders.
00077 ////////////////////////////////////////////////////////////////////
00078 INLINE void LightMutexHolder::
00079 operator = (const LightMutexHolder &copy) {
00080   nassertv(false);
00081 }
 All Classes Functions Variables Enumerations