comparison Framework/Plugins/StorageBackend.h @ 231:0a9b48d19643

removed mutex out of DatabaseManager
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 06 Apr 2021 11:59:31 +0200
parents 675f8322eb7c
children b97a537f4613
comparison
equal deleted inserted replaced
230:675f8322eb7c 231:0a9b48d19643
23 23
24 #include "../Common/DatabaseManager.h" 24 #include "../Common/DatabaseManager.h"
25 25
26 #include <orthanc/OrthancCDatabasePlugin.h> 26 #include <orthanc/OrthancCDatabasePlugin.h>
27 27
28 #include <boost/thread/mutex.hpp>
29
28 30
29 namespace OrthancDatabases 31 namespace OrthancDatabases
30 { 32 {
31 class StorageBackend : public boost::noncopyable 33 class StorageBackend : public boost::noncopyable
32 { 34 {
33 private: 35 private:
36 boost::mutex mutex_;
34 std::unique_ptr<DatabaseManager> manager_; 37 std::unique_ptr<DatabaseManager> manager_;
35 38
36 DatabaseManager& GetManager(); 39 DatabaseManager& GetManager();
37 40
38 protected: 41 protected:
52 }; 55 };
53 56
54 class Accessor : public boost::noncopyable 57 class Accessor : public boost::noncopyable
55 { 58 {
56 private: 59 private:
57 DatabaseManager& manager_; 60 boost::mutex::scoped_lock lock_;
61 DatabaseManager& manager_;
58 62
59 public: 63 public:
60 Accessor(StorageBackend& backend) : 64 Accessor(StorageBackend& backend) :
65 lock_(backend.mutex_),
61 manager_(backend.GetManager()) 66 manager_(backend.GetManager())
62 { 67 {
63 } 68 }
64 69
65 void Create(const std::string& uuid, 70 void Create(const std::string& uuid,