Panda3D
 All Classes Functions Variables Enumerations
pmutex.h
00001 // Filename: pmutex.h
00002 // Created by:  cary (16Sep98)
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 #ifndef PMUTEX_H
00016 #define PMUTEX_H
00017 
00018 #include "pandabase.h"
00019 #include "mutexDebug.h"
00020 #include "mutexDirect.h"
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //       Class : Mutex
00024 // Description : A standard mutex, or mutual exclusion lock.  Only one
00025 //               thread can hold ("lock") a mutex at any given time;
00026 //               other threads trying to grab the mutex will block
00027 //               until the holding thread releases it.
00028 //
00029 //               The standard mutex is not reentrant: a thread may not
00030 //               attempt to lock it twice.  Although this may happen
00031 //               to work on some platforms (e.g. Win32), it will not
00032 //               work on all platforms; on some platforms, a thread
00033 //               can deadlock itself by attempting to lock the same
00034 //               mutex twice.  If your code requires a reentrant
00035 //               mutex, use the ReMutex class instead.
00036 //
00037 //               This class inherits its implementation either from
00038 //               MutexDebug or MutexDirect, depending on the
00039 //               definition of DEBUG_THREADS.
00040 ////////////////////////////////////////////////////////////////////
00041 #ifdef DEBUG_THREADS
00042 class EXPCL_PANDA_PIPELINE Mutex : public MutexDebug
00043 #else
00044 class EXPCL_PANDA_PIPELINE Mutex : public MutexDirect
00045 #endif  // DEBUG_THREADS
00046 {
00047 PUBLISHED:
00048   INLINE Mutex();
00049 public:
00050   INLINE Mutex(const char *name);
00051 PUBLISHED:
00052   INLINE Mutex(const string &name);
00053   INLINE ~Mutex();
00054 private:
00055   INLINE Mutex(const Mutex &copy);
00056   INLINE void operator = (const Mutex &copy);
00057 
00058 public:
00059   // This is a global mutex set aside for the purpose of protecting
00060   // Notify messages from being interleaved between threads.
00061   static Mutex _notify_mutex;
00062 };
00063 
00064 #include "pmutex.I"
00065 
00066 #endif
 All Classes Functions Variables Enumerations