# beemutex.h

Go to the documentation of this file.

    00001
    00002
    00003
    00004
    00005
    00006
    00007
    00008
    00009
    00010
    00011
    00012
    00013
    00014
    00015
    00016
    00017
    00018
    00019 /***********************************************************************
    00020  Copyright (c) 2004 Beeyond Software Holding BV and (c) 2007-2008
    00021  by Educational Technology Resources, Inc.  Others may also hold
    00022  copyrights on code in this file.  See the CREDITS.txt file in the
    00023  top directory of the distribution for details.
    00024
    00025  This file is part of MySQL++.
    00026
    00027  MySQL++ is free software; you can redistribute it and/or modify it
    00028  under the terms of the GNU Lesser General Public License as published
    00029  by the Free Software Foundation; either version 2.1 of the License, or
    00030  (at your option) any later version.
    00031
    00032  MySQL++ is distributed in the hope that it will be useful, but WITHOUT
    00033  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    00034  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
    00035  License for more details.
    00036
    00037  You should have received a copy of the GNU Lesser General Public
    00038  License along with MySQL++; if not, write to the Free Software
    00039  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
    00040  USA
    00041 ***********************************************************************/
    00042
    00043 #if !defined(MYSQLPP_BEEMUTEX_H)
    00044 #define MYSQLPP_BEEMUTEX_H
    00045
    00046 #include "exceptions.h"
    00047
    00048 namespace mysqlpp {
    00049
    00057 class MYSQLPP_EXPORT BeecryptMutex
    00058 {
    00059 public:
    00064         BeecryptMutex() throw (MutexFailed);
    00065
    00069         ~BeecryptMutex();
    00070
    00073         void lock() throw (MutexFailed);
    00074
    00077         bool trylock() throw (MutexFailed);
    00078
    00080         void unlock() throw (MutexFailed);
    00081
    00082 private:
    00083         void* pmutex_;
    00084 };
    00085
    00086
    00094
    00095 class ScopedLock
    00096 {
    00097 public:
    00099         explicit ScopedLock(BeecryptMutex& mutex) :
    00100         mutex_(mutex)
    00101         {
    00102                 mutex.lock();
    00103         }
    00104
    00106         ~ScopedLock() { mutex_.unlock(); }
    00107
    00108 private:
    00109         ScopedLock(const ScopedLock&);                          // can't copy
    00110         ScopedLock& operator =(const ScopedLock&);      // can't assign
    00111
    00112         BeecryptMutex& mutex_;
    00113 };
    00114
    00115 } // end namespace mysqlpp
    00116
    00117 #endif // !defined(MYSQLPP_BEEMUTEX_H)
    00118