beemutex.h
Go to the documentation of this file.
/***********************************************************************
Copyright (c) 2004 Beeyond Software Holding BV and (c) 2007-2008
by Educational Technology Resources, Inc. Others may also hold
copyrights on code in this file. See the CREDITS.txt file in the
top directory of the distribution for details.
This file is part of MySQL++.
MySQL++ is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
MySQL++ is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MySQL++; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
***********************************************************************/
#if !defined(MYSQLPP_BEEMUTEX_H)
#define MYSQLPP_BEEMUTEX_H
#include "exceptions.h"
namespace mysqlpp {
class MYSQLPP_EXPORT BeecryptMutex
{
public:
BeecryptMutex() throw (MutexFailed);
~BeecryptMutex();
void lock() throw (MutexFailed);
bool trylock() throw (MutexFailed);
void unlock() throw (MutexFailed);
private:
void* pmutex_;
};
class ScopedLock
{
public:
explicit ScopedLock(BeecryptMutex& mutex) :
mutex_(mutex)
{
mutex.lock();
}
~ScopedLock() { mutex_.unlock(); }
private:
ScopedLock(const ScopedLock&); // can't copy
ScopedLock& operator =(const ScopedLock&); // can't assign
BeecryptMutex& mutex_;
};
} // end namespace mysqlpp
#endif // !defined(MYSQLPP_BEEMUTEX_H)
mysqlpp::ScopedLock::ScopedLock
ScopedLock(BeecryptMutex &mutex)
Lock the mutex.
Definition: beemutex.h:99
mysqlpp::MutexFailed
Exception thrown when a BeecryptMutex object fails.
Definition: exceptions.h:389
mysqlpp::ScopedLock
Wrapper around BeecryptMutex to add scope-bound locking and unlocking.
Definition: beemutex.h:95
mysqlpp::ScopedLock::~ScopedLock
~ScopedLock()
Unlock the mutex.
Definition: beemutex.h:106
mysqlpp::BeecryptMutex::lock
void lock()
Acquire the mutex, blocking if it can&#39;t be acquired immediately.
Definition: beemutex.cpp:106
exceptions.h
Declares the MySQL++-specific exception classes.
mysqlpp::BeecryptMutex
Wrapper around platform-specific mutexes.
Definition: beemutex.h:57
mysqlpp::BeecryptMutex::unlock
void unlock()
Release the mutex.
Definition: beemutex.cpp:163