Panda3D
|
00001 // Filename: mutexSimpleImpl.h 00002 // Created by: drose (19Jun07) 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 MUTEXSIMPLEIMPL_H 00016 #define MUTEXSIMPLEIMPL_H 00017 00018 #include "pandabase.h" 00019 #include "selectThreadImpl.h" 00020 00021 #ifdef THREAD_SIMPLE_IMPL 00022 00023 #include "blockerSimple.h" 00024 #include "threadSimpleImpl.h" 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : MutexSimpleImpl 00028 // Description : This is the mutex implementation for the simple, 00029 // simulated threads case. It's designed to be as 00030 // lightweight as possible, of course. This 00031 // implementation simply yields the thread when the 00032 // mutex would block. 00033 // 00034 // We can't define this class in dtoolbase along with 00035 // the other mutex implementations, because this 00036 // implementation requires knowing about the 00037 // SimpleThreadManager. This complicates the 00038 // MutexDirect and MutexDebug definitions (we have to 00039 // define a MutexImpl, for code before pipeline to 00040 // use--which maps to MutexDummyImpl--and a 00041 // MutexTrueImpl, for code after pipeline to use--which 00042 // maps to this class, MutexSimpleImpl). 00043 //////////////////////////////////////////////////////////////////// 00044 class EXPCL_PANDA_PIPELINE MutexSimpleImpl : public BlockerSimple { 00045 public: 00046 INLINE MutexSimpleImpl(); 00047 INLINE ~MutexSimpleImpl(); 00048 00049 INLINE void acquire(); 00050 INLINE bool try_acquire(); 00051 INLINE void release(); 00052 INLINE void release_quietly(); 00053 00054 private: 00055 void do_acquire(); 00056 void do_release(); 00057 void do_release_quietly(); 00058 00059 friend class ThreadSimpleManager; 00060 }; 00061 00062 #include "mutexSimpleImpl.I" 00063 00064 #endif // THREAD_SIMPLE_IMPL 00065 00066 #endif