Panda3D

conditionVarSpinlockImpl.h

00001 // Filename: conditionVarSpinlockImpl.h
00002 // Created by:  drose (11Apr06)
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 CONDITIONVARSPINLOCKIMPL_H
00016 #define CONDITIONVARSPINLOCKIMPL_H
00017 
00018 #include "pandabase.h"
00019 #include "selectThreadImpl.h"
00020 
00021 #ifdef MUTEX_SPINLOCK
00022 
00023 #include "mutexSpinlockImpl.h"
00024 #include "pnotify.h"
00025 #include "atomicAdjust.h"
00026 
00027 class MutexSpinlockImpl;
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : ConditionVarSpinlockImpl
00031 // Description : Uses a simple user-space spinlock to implement a
00032 //               condition variable.  It is usually not a good idea to
00033 //               use this implementation, unless you are building
00034 //               Panda for a specific application on a specific SMP
00035 //               machine, and you are confident that you have at least
00036 //               as many CPU's as you have threads.
00037 ////////////////////////////////////////////////////////////////////
00038 class EXPCL_PANDA_PIPELINE ConditionVarSpinlockImpl {
00039 public:
00040   INLINE ConditionVarSpinlockImpl(MutexSpinlockImpl &mutex);
00041   INLINE ~ConditionVarSpinlockImpl();
00042 
00043   void wait();
00044   INLINE void notify();
00045   INLINE void notify_all();
00046 
00047 private:
00048   MutexSpinlockImpl &_mutex;
00049   TVOLATILE AtomicAdjust::Integer _event;
00050 };
00051 
00052 #include "conditionVarSpinlockImpl.I"
00053 
00054 #endif  // MUTEX_SPINLOCK
00055 
00056 #endif
 All Classes Functions Variables Enumerations