annotate Framework/Plugins/IndexConnectionsPool.h @ 374:4a3985088723 db-protobuf

moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 28 Mar 2023 14:51:17 +0200
parents
children 824d70ce85ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
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
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 namespace OrthancDatabases
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 class IndexConnectionsPool : public boost::noncopyable
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 private:
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 class ManagerReference;
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 std::unique_ptr<IndexBackend> backend_;
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 OrthancPluginContext* context_;
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 boost::shared_mutex connectionsMutex_;
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 size_t countConnections_;
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 std::list<DatabaseManager*> connections_;
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 Orthanc::SharedMessageQueue availableConnections_;
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 public:
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 IndexConnectionsPool(IndexBackend* backend,
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 size_t countConnections);
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 ~IndexConnectionsPool();
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 OrthancPluginContext* GetContext() const
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 return context_;
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
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 void OpenConnections();
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 CloseConnections();
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 class Accessor : public boost::noncopyable
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 private:
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 boost::shared_lock<boost::shared_mutex> lock_;
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 IndexConnectionsPool& pool_;
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 DatabaseManager* manager_;
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 public:
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 Accessor(IndexConnectionsPool& pool);
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 ~Accessor();
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 IndexBackend& GetBackend() const;
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 DatabaseManager& GetManager() 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 };
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 }