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