ulxr_mutex.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                   ulxr_mutex.h  -  mutex handling
00003                       -------------------
00004     begin                : Thu Dec 03 2002
00005     copyright            : (C) 2002-2007 by Ewald Arnold
00006     email                : ulxmlrpcpp@ewald-arnold.de
00007 
00008     $Id: ulxr_mutex.h 940 2006-12-30 18:22:05Z ewald-arnold $
00009 
00010  ***************************************************************************/
00011 
00012 /**************************************************************************
00013  *
00014  * This program is free software; you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser General Public License as
00016  * published by the Free Software Foundation; either version 2 of the License,
00017  * or (at your option) any later version.
00018  *
00019  * This program is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this program; if not, write to the Free Software
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00027  *
00028  ***************************************************************************/
00029 
00030 #ifndef ULXR_MUTEX_H
00031 #define ULXR_MUTEX_H
00032 
00033 #include <ulxmlrpcpp/ulxmlrpcpp.h>  // always first header
00034 
00035 #ifdef __WIN32__
00036 #include <windows.h>
00037 #endif
00038 
00039 #ifdef __unix__
00040 #include <pthread.h>
00041 #endif
00042 
00043 
00044 namespace ulxr {
00045 
00046 
00049 class ULXR_API_DECL0 Mutex
00050 {
00051  public:
00052 
00055    class ULXR_API_DECL0 Locker
00056    {
00057     public:
00058 
00062      Locker(Mutex &mtx);
00063 
00066      ~Locker() throw();
00067 
00068     private:
00069 
00070       Mutex *mutex;
00071    };
00072 
00075    class ULXR_API_DECL0 TryLocker
00076    {
00077     public:
00078 
00082      TryLocker(Mutex &mtx);
00083 
00086      ~TryLocker() throw();
00087 
00091      bool isLocked();
00092 
00093     private:
00094 
00095       Mutex *mutex;
00096       bool   locked;
00097    };
00098 
00101    Mutex();
00102 
00105    ~Mutex() throw();
00106 
00109    void lock();
00110 
00113    void  unlock();
00114 
00118    bool tryLock();
00119 
00120  private:
00121 
00122 #ifdef __WIN32__
00123    HANDLE   handle;
00124 #else
00125    pthread_mutex_t handle;
00126 #endif
00127 };
00128 
00129 
00130 }  // namespace ulxr
00131 
00132 
00133 #endif // ULXR_MUTEX_H

Generated on Sun Aug 19 20:08:57 2007 for ulxmlrpcpp by  doxygen 1.5.1