aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-28 23:37:39 +0000
committerlloyd <[email protected]>2008-09-28 23:37:39 +0000
commitce4f262d2519324e2a5f0dd9d5b786e43c968f96 (patch)
treee4f278140be9cca7588ee273d4e59550718d4f73 /include
parenta6f3801debb5239505ec2c9523a7fec5a9bbb070 (diff)
Move Default_Mutex (now Noop_Mutex) into module
Diffstat (limited to 'include')
-rw-r--r--include/modules.h4
-rw-r--r--include/mutex.h24
2 files changed, 17 insertions, 11 deletions
diff --git a/include/modules.h b/include/modules.h
index 48a07c437..69a6e1ffb 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -18,7 +18,7 @@ namespace Botan {
class BOTAN_DLL Modules
{
public:
- virtual class Mutex_Factory* mutex_factory() const = 0;
+ virtual class Mutex_Factory* mutex_factory(bool) const = 0;
virtual std::string default_allocator() const = 0;
@@ -34,7 +34,7 @@ class BOTAN_DLL Modules
class BOTAN_DLL Builtin_Modules : public Modules
{
public:
- class Mutex_Factory* mutex_factory() const;
+ class Mutex_Factory* mutex_factory(bool) const;
std::string default_allocator() const;
diff --git a/include/mutex.h b/include/mutex.h
index 518da8fd5..832a2058e 100644
--- a/include/mutex.h
+++ b/include/mutex.h
@@ -32,24 +32,30 @@ class BOTAN_DLL Mutex_Factory
};
/*************************************************
-* Default Mutex Factory *
+* Mutex Holding Class *
*************************************************/
-class BOTAN_DLL Default_Mutex_Factory : public Mutex_Factory
+class BOTAN_DLL Mutex_Holder
{
public:
- Mutex* make();
+ Mutex_Holder(Mutex* m) : mux(m)
+ {
+ if(!mux)
+ throw Invalid_Argument("Mutex_Holder: Argument was NULL");
+ mux->lock();
+ }
+
+ ~Mutex_Holder() { mux->unlock(); }
+ private:
+ Mutex* mux;
};
/*************************************************
-* Mutex Holding Class *
+* Default Mutex Factory *
*************************************************/
-class BOTAN_DLL Mutex_Holder
+class BOTAN_DLL Default_Mutex_Factory : public Mutex_Factory
{
public:
- Mutex_Holder(Mutex*);
- ~Mutex_Holder();
- private:
- Mutex* mux;
+ Mutex* make();
};
}