aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-06-23 10:55:31 +0000
committerlloyd <[email protected]>2006-06-23 10:55:31 +0000
commit78e27f1dd2c7eb22402fe0e16b6daebe9d307e35 (patch)
treeb17e4f6741b467f8693fce9d39a7b5f3124f5f99 /src
parentd396aa30535c4d3a24e1593df2995eece0f2d3d4 (diff)
Add a new exception type in src/mutex.cpp to make the code a little more
readable.
Diffstat (limited to 'src')
-rw-r--r--src/mutex.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mutex.cpp b/src/mutex.cpp
index f96849409..074da7e42 100644
--- a/src/mutex.cpp
+++ b/src/mutex.cpp
@@ -33,17 +33,27 @@ Mutex* Mutex_Factory::make()
class Default_Mutex : public Mutex
{
public:
+ class Mutex_State_Error : public Internal_Error
+ {
+ public:
+ Mutex_State_Error(const std::string& where)
+ {
+ set_msg("Default_Mutex::" + where + ": Mutex is already " +
+ where + "ed");
+ }
+ };
+
void lock()
{
if(locked)
- throw Internal_Error("Default_Mutex::lock: Mutex is already locked");
+ throw Mutex_State_Error("lock");
locked = true;
}
void unlock()
{
if(!locked)
- throw Internal_Error("Default_Mutex::unlock: Mutex is already unlocked");
+ throw Mutex_State_Error("unlock");
locked = false;
}