MySQL++ Reference Manual

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

beemutex.h
Go to the documentation of this file.
1
19 /***********************************************************************
20 Copyright (c) 2004 Beeyond Software Holding BV and (c) 2007-2008
21 by Educational Technology Resources, Inc. Others may also hold
22 copyrights on code in this file. See the CREDITS.txt file in the
23 top directory of the distribution for details.
24
25 This file is part of MySQL++.
26
27 MySQL++ is free software; you can redistribute it and/or modify it
28 under the terms of the GNU Lesser General Public License as published
29 by the Free Software Foundation; either version 2.1 of the License, or
30 (at your option) any later version.
31
32 MySQL++ is distributed in the hope that it will be useful, but WITHOUT
33 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
34 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
35 License for more details.
36
37 You should have received a copy of the GNU Lesser General Public
38 License along with MySQL++; if not, write to the Free Software
39 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
40 USA
41 ***********************************************************************/
42
43 #if !defined(MYSQLPP_BEEMUTEX_H)
44 #define MYSQLPP_BEEMUTEX_H
45
46 #include "exceptions.h"
47
48 namespace mysqlpp {
49
57 class MYSQLPP_EXPORT BeecryptMutex
58 {
59 public:
64 BeecryptMutex() throw (MutexFailed);
65
69 ~BeecryptMutex();
70
73 void lock() throw (MutexFailed);
74
77 bool trylock() throw (MutexFailed);
78
80 void unlock() throw (MutexFailed);
81
82 private:
83 void* pmutex_;
84 };
85
86
94
95 class ScopedLock
96 {
97 public:
99 explicit ScopedLock(BeecryptMutex& mutex) :
100 mutex_(mutex)
101 {
102 mutex.lock();
103 }
104
106 ~ScopedLock() { mutex_.unlock(); }
107
108 private:
109 ScopedLock(const ScopedLock&); // can't copy
110 ScopedLock& operator =(const ScopedLock&); // can't assign
111
112 BeecryptMutex& mutex_;
113 };
114
115 } // end namespace mysqlpp
116
117 #endif // !defined(MYSQLPP_BEEMUTEX_H)
118
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