diff options
author | lloyd <[email protected]> | 2009-11-02 12:12:40 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-11-02 12:12:40 +0000 |
commit | b8658279904708d0690e473fb85942d5da23d2fc (patch) | |
tree | 65528378bd0089287ca0927a13a6e0a012f7bc78 /src/algo_factory/algo_cache.h | |
parent | 6b617a55bd02bcc4fdb6f76af92e0cb65fd838a2 (diff) | |
parent | 92f31b22dfe2aa1b2bde84cbaf4ce7365fa4ec68 (diff) |
propagate from branch 'net.randombit.botan' (head 2773c2310e8c0a51975987a2dd6c5824c8d43882)
to branch 'net.randombit.botan.c++0x' (head f13cf5d7e89706c882604299b508f356c20aae3a)
Diffstat (limited to 'src/algo_factory/algo_cache.h')
-rw-r--r-- | src/algo_factory/algo_cache.h | 16 |
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; } } |