Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomNetworking/TimeoutDicomConnectionManager.h @ 4767:e1711b6e141f
Fix computation of the estimated time of arrival in jobs
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 18 Aug 2021 15:16:39 +0200 |
parents | d9473bd5ed43 |
children | 7053502fbf97 |
rev | line source |
---|---|
2603 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
2603 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * the License, or (at your option) any later version. |
2603 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
15 * Lesser General Public License for more details. |
2603 | 16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
2603 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
25 #if !defined(ORTHANC_ENABLE_DCMTK_NETWORKING) |
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
26 # error The macro ORTHANC_ENABLE_DCMTK_NETWORKING must be defined |
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
27 #endif |
2603 | 28 |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
29 #if ORTHANC_ENABLE_DCMTK_NETWORKING != 1 |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
30 # error The macro ORTHANC_ENABLE_DCMTK_NETWORKING must be 1 to use this file |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
31 #endif |
2644
5b3bfdf6b790
fix Orthanc framework without DICOM support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2608
diff
changeset
|
32 |
5b3bfdf6b790
fix Orthanc framework without DICOM support
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2608
diff
changeset
|
33 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
34 #include "../Compatibility.h" |
3863
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
35 #include "DicomStoreUserConnection.h" |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
36 |
2608
25225f0b4f33
simplification wrt. dicom connection manager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
37 #include <boost/date_time/posix_time/posix_time.hpp> |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
38 #include <boost/thread/mutex.hpp> |
2603 | 39 |
40 namespace Orthanc | |
41 { | |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
42 /** |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
43 * This class corresponds to a singleton to a DICOM SCU connection. |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
44 **/ |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
45 class TimeoutDicomConnectionManager : public boost::noncopyable |
2603 | 46 { |
47 private: | |
3863
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
48 boost::mutex mutex_; |
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
49 std::unique_ptr<DicomStoreUserConnection> connection_; |
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
50 boost::posix_time::ptime lastUse_; |
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
51 boost::posix_time::time_duration timeout_; |
2603 | 52 |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
53 // Mutex must be locked |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
54 void TouchInternal(); |
2603 | 55 |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
56 // Mutex must be locked |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
57 void OpenInternal(const std::string& localAet, |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
58 const RemoteModalityParameters& remote); |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
59 |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
60 // Mutex must be locked |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
61 void CloseInternal(); |
2603 | 62 |
63 public: | |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
64 class Lock : public boost::noncopyable |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
65 { |
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
66 private: |
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
67 TimeoutDicomConnectionManager& that_; |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
68 boost::mutex::scoped_lock lock_; |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
69 |
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
70 public: |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
71 Lock(TimeoutDicomConnectionManager& that, |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
72 const std::string& localAet, |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
73 const RemoteModalityParameters& remote); |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
74 |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
75 ~Lock(); |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
76 |
3863
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
77 DicomStoreUserConnection& GetConnection(); |
3850
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
78 }; |
d729d6e8b484
removing useless abstraction IDicomConnectionManager
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
79 |
2603 | 80 TimeoutDicomConnectionManager() : |
81 timeout_(boost::posix_time::milliseconds(1000)) | |
82 { | |
83 } | |
84 | |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
85 void SetInactivityTimeout(unsigned int milliseconds); |
2603 | 86 |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
87 unsigned int GetInactivityTimeout(); // In milliseconds |
2603 | 88 |
89 void Close(); | |
90 | |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3850
diff
changeset
|
91 void CloseIfInactive(); |
2603 | 92 }; |
93 } |