• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ut_mutex.h

Go to the documentation of this file.
00001 /* AbiSource Program Utilities
00002  * Copyright (C) 2002 Dom Lachowicz <cinamod@hotmail.com>
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
00018  */
00019 #ifndef UT_MUTEX_H
00020 #define UT_MUTEX_H
00021 
00022 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
00023  * so even if it's commented out in-file that's still a lot of work for
00024  * the preprocessor to do...
00025  */
00026 #ifndef UT_TYPES_H
00027 #include "ut_types.h"
00028 #endif
00029 
00030 class UT_MutexImpl;
00031 class UT_MutexAcquirer;
00032 
00041 class ABI_EXPORT UT_Mutex
00042 {
00043     friend class UT_MutexImpl;
00044     friend class UT_MutexAcquirer;
00045 
00046  public:
00047     UT_Mutex ();
00048     ~UT_Mutex ();
00049 
00050   void lock ();
00051   void unlock ();
00052 
00053  private:
00054 
00055 
00056   // no impls
00057   UT_Mutex (const UT_Mutex & other);
00058   UT_Mutex & operator=(const UT_Mutex & other);
00059 
00060   UT_MutexImpl * m_pimpl;
00061 };
00062 
00078 class ABI_EXPORT UT_MutexAcquirer
00079 {
00080  public:
00081 
00082   UT_MutexAcquirer (UT_Mutex & inMutex)
00083     : m_mutex(inMutex)
00084     {
00085       m_mutex.lock ();
00086     }
00087 
00088   ~UT_MutexAcquirer ()
00089     {
00090       m_mutex.unlock();
00091     }
00092 
00093  private:
00094   // no impls
00095   UT_MutexAcquirer ();
00096   UT_MutexAcquirer (const UT_MutexAcquirer & other);
00097   UT_MutexAcquirer & operator=(const UT_MutexAcquirer &other);
00098 
00099   UT_Mutex & m_mutex;
00100 };
00101 
00102 #endif /* UT_MUTEX_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1