diff options
author | lloyd <[email protected]> | 2010-08-04 12:50:23 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-08-04 12:50:23 +0000 |
commit | e19f1554004830e99872c13b8d5fa678b93d586a (patch) | |
tree | 51ebc37d2bda7ee4ad9d16f8e0408ac9dd844dd2 /Attic/mutex/noop_mutex/mux_noop.cpp | |
parent | 5d9eecf1646facfff9b20e9932894fce0d0ff39c (diff) | |
parent | 49ebca0d092bcb6a208604f7ac8d1b798f5170fc (diff) |
propagate from branch 'net.randombit.botan' (head 717a9d103aa80e6d66c04e3a23cf173aadf56ceb)
to branch 'net.randombit.botan.c++0x' (head c9759e8ebc2f360696a11f2d00fc218d7a8bf744)
Diffstat (limited to 'Attic/mutex/noop_mutex/mux_noop.cpp')
-rw-r--r-- | Attic/mutex/noop_mutex/mux_noop.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Attic/mutex/noop_mutex/mux_noop.cpp b/Attic/mutex/noop_mutex/mux_noop.cpp new file mode 100644 index 000000000..18151274a --- /dev/null +++ b/Attic/mutex/noop_mutex/mux_noop.cpp @@ -0,0 +1,50 @@ +/* +* No-Op Mutex Factory +* (C) 1999-2007 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include <botan/internal/mux_noop.h> + +namespace Botan { + +/* +* No-Op Mutex Factory +*/ +Mutex* Noop_Mutex_Factory::make() + { + class Noop_Mutex : public Mutex + { + public: + class Mutex_State_Error : public Internal_Error + { + public: + Mutex_State_Error(const std::string& where) : + Internal_Error("Noop_Mutex::" + where + ": " + + "Mutex is already " + where + "ed") {} + }; + + void lock() + { + if(locked) + throw Mutex_State_Error("lock"); + locked = true; + } + + void unlock() + { + if(!locked) + throw Mutex_State_Error("unlock"); + locked = false; + } + + Noop_Mutex() { locked = false; } + private: + bool locked; + }; + + return new Noop_Mutex; + } + +} |