Mercurial > hg > orthanc-databases
comparison Framework/Plugins/IndexConnectionsPool.h @ 387:f35b17a38301
integration db-protobuf->mainline
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 03 Apr 2023 17:12:08 +0200 |
parents | 824d70ce85ff |
children | 3d6886f3e5b3 |
comparison
equal
deleted
inserted
replaced
371:c1fe28de1bf6 | 387:f35b17a38301 |
---|---|
1 /** | |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium | |
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
7 * | |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Affero General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Affero General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Affero General Public License | |
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
23 #pragma once | |
24 | |
25 #include "IndexBackend.h" | |
26 | |
27 #include <MultiThreading/SharedMessageQueue.h> | |
28 | |
29 #include <list> | |
30 | |
31 namespace OrthancDatabases | |
32 { | |
33 class IndexConnectionsPool : public boost::noncopyable | |
34 { | |
35 private: | |
36 class ManagerReference; | |
37 | |
38 std::unique_ptr<IndexBackend> backend_; | |
39 OrthancPluginContext* context_; | |
40 boost::shared_mutex connectionsMutex_; | |
41 size_t countConnections_; | |
42 std::list<DatabaseManager*> connections_; | |
43 Orthanc::SharedMessageQueue availableConnections_; | |
44 | |
45 public: | |
46 IndexConnectionsPool(IndexBackend* backend /* takes ownership */, | |
47 size_t countConnections); | |
48 | |
49 ~IndexConnectionsPool(); | |
50 | |
51 OrthancPluginContext* GetContext() const | |
52 { | |
53 return context_; | |
54 } | |
55 | |
56 void OpenConnections(); | |
57 | |
58 void CloseConnections(); | |
59 | |
60 class Accessor : public boost::noncopyable | |
61 { | |
62 private: | |
63 boost::shared_lock<boost::shared_mutex> lock_; | |
64 IndexConnectionsPool& pool_; | |
65 DatabaseManager* manager_; | |
66 | |
67 public: | |
68 Accessor(IndexConnectionsPool& pool); | |
69 | |
70 ~Accessor(); | |
71 | |
72 IndexBackend& GetBackend() const; | |
73 | |
74 DatabaseManager& GetManager() const; | |
75 }; | |
76 }; | |
77 } |