mutex.h

Go to the documentation of this file.
00001 #ifndef MUTEX_CLASS
00002 #define MUTEX_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : mutex                                                             *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1996-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "contracts.h"
00019 
00021 
00030 namespace basis {
00031 
00032 class mutex : public virtual base_synchronizer
00033 {
00034 public:
00035   mutex();  
00036 
00037   virtual ~mutex();
00039 
00041   void construct();
00042 
00044   void destruct();
00045 
00046   void lock();
00048 
00050   void unlock();
00052 
00053   virtual void establish_lock();
00055   virtual void repeal_lock();
00057 
00058 private:
00059   void *c_os_mutex;  
00060 
00061   void defang();
00063 
00068   mutex(const mutex &);  
00069   mutex &operator =(const mutex &);  
00070 };
00071 
00073 
00075 
00112 class auto_synchronizer
00113 {
00114 public:
00115   auto_synchronizer(base_synchronizer &locker) : _locker(locker)
00116           { _locker.establish_lock(); }
00118 
00123   ~auto_synchronizer() { _locker.repeal_lock(); }
00125 
00126 private:
00127   base_synchronizer &_locker;  
00128 
00129   // disallowed.
00130   auto_synchronizer(const auto_synchronizer &locker);
00131   auto_synchronizer &operator =(const auto_synchronizer &locker);
00132 };
00133 
00134 } //namespace.
00135 
00136 #endif
00137 
Generated on Sat Jan 28 04:22:17 2012 for hoople2 project by  doxygen 1.6.3