aboutsummaryrefslogtreecommitdiffstats
path: root/src/algo_factory/algo_cache.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-10-13 16:05:37 +0000
committerlloyd <[email protected]>2009-10-13 16:05:37 +0000
commit6f68dc5485ebd41fdef837ab651a47a893d84408 (patch)
tree3cda82570052b7bed24df2754c2245479188488a /src/algo_factory/algo_cache.h
parent9268a0455a07d31a66364aa5b7594bd75250b466 (diff)
parent1b0448fae6652a2da7f0de1fdcd2bbcda9836ca9 (diff)
propagate from branch 'net.randombit.botan' (head 139d6957d20f0b1202e0eacc63cb011588faffde)
to branch 'net.randombit.botan.c++0x' (head c16676fa6c393bc3f46a044755ce525a013380a6)
Diffstat (limited to 'src/algo_factory/algo_cache.h')
-rw-r--r--src/algo_factory/algo_cache.h16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/algo_factory/algo_cache.h b/src/algo_factory/algo_cache.h
index 08b25cd47..4b264dcc1 100644
--- a/src/algo_factory/algo_cache.h
+++ b/src/algo_factory/algo_cache.h
@@ -8,8 +8,9 @@
#ifndef BOTAN_ALGORITHM_CACHE_TEMPLATE_H__
#define BOTAN_ALGORITHM_CACHE_TEMPLATE_H__
-#include <botan/mutex.h>
+#include <botan/types.h>
#include <botan/stl_util.h>
+#include <mutex>
#include <string>
#include <vector>
#include <map>
@@ -50,7 +51,6 @@ class Algorithm_Cache
*/
std::vector<std::string> providers_of(const std::string& algo_name);
- Algorithm_Cache(Mutex* m) : mutex(m) {}
~Algorithm_Cache();
private:
typedef typename std::map<std::string, std::map<std::string, T*> >::iterator
@@ -60,7 +60,7 @@ class Algorithm_Cache
algorithms_iterator find_algorithm(const std::string& algo_spec);
- Mutex* mutex;
+ std::mutex mutex;
std::map<std::string, std::string> aliases;
std::map<std::string, std::string> pref_providers;
std::map<std::string, std::map<std::string, T*> > algorithms;
@@ -96,7 +96,7 @@ template<typename T>
const T* Algorithm_Cache<T>::get(const std::string& algo_spec,
const std::string& requested_provider)
{
- Mutex_Holder lock(mutex);
+ std::lock_guard<std::mutex> lock(mutex);
algorithms_iterator algo = find_algorithm(algo_spec);
if(algo == algorithms.end()) // algo not found at all (no providers)
@@ -148,7 +148,7 @@ void Algorithm_Cache<T>::add(T* algo,
if(!algo)
return;
- Mutex_Holder lock(mutex);
+ std::lock_guard<std::mutex> lock(mutex);
delete algorithms[algo->name()][provider];
algorithms[algo->name()][provider] = algo;
@@ -166,7 +166,7 @@ void Algorithm_Cache<T>::add(T* algo,
template<typename T> std::vector<std::string>
Algorithm_Cache<T>::providers_of(const std::string& algo_name)
{
- Mutex_Holder lock(mutex);
+ std::lock_guard<std::mutex> lock(mutex);
std::vector<std::string> providers;
@@ -193,7 +193,7 @@ template<typename T>
void Algorithm_Cache<T>::set_preferred_provider(const std::string& algo_spec,
const std::string& provider)
{
- Mutex_Holder lock(mutex);
+ std::lock_guard<std::mutex> lock(mutex);
pref_providers[algo_spec] = provider;
}
@@ -218,8 +218,6 @@ Algorithm_Cache<T>::~Algorithm_Cache()
++algo;
}
-
- delete mutex;
}
}