Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyLoadersContext.cpp @ 1899:917500c46fe0
moved the Platform folder from the Applications folder to the Stone library itself
author | Alain Mazy <am@osimis.io> |
---|---|
date | Sat, 29 Jan 2022 12:47:32 +0100 |
parents | |
children | 07964689cb0b |
comparison
equal
deleted
inserted
replaced
1898:a5e54bd87b25 | 1899:917500c46fe0 |
---|---|
1 /** | |
2 * Stone of Orthanc | |
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 Lesser 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 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
19 * License along with this program. If not, see | |
20 * <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #include "WebAssemblyLoadersContext.h" | |
25 | |
26 namespace OrthancStone | |
27 { | |
28 class WebAssemblyLoadersContext::Locker : public ILoadersContext::ILock | |
29 { | |
30 private: | |
31 WebAssemblyLoadersContext& that_; | |
32 | |
33 public: | |
34 explicit Locker(WebAssemblyLoadersContext& that) : | |
35 that_(that) | |
36 { | |
37 } | |
38 | |
39 virtual ILoadersContext& GetContext() const ORTHANC_OVERRIDE | |
40 { | |
41 return that_; | |
42 } | |
43 | |
44 virtual IObservable& GetOracleObservable() const ORTHANC_OVERRIDE | |
45 { | |
46 return that_.oracle_.GetOracleObservable(); | |
47 } | |
48 | |
49 virtual void Schedule(boost::shared_ptr<IObserver> receiver, | |
50 int priority, | |
51 IOracleCommand* command /* Takes ownership */) ORTHANC_OVERRIDE | |
52 { | |
53 that_.scheduler_->Schedule(receiver, priority, command); | |
54 } | |
55 | |
56 virtual void CancelRequests(boost::shared_ptr<IObserver> receiver) ORTHANC_OVERRIDE | |
57 { | |
58 that_.scheduler_->CancelRequests(receiver); | |
59 } | |
60 | |
61 virtual void CancelAllRequests() ORTHANC_OVERRIDE | |
62 { | |
63 that_.scheduler_->CancelAllRequests(); | |
64 } | |
65 | |
66 virtual void AddLoader(boost::shared_ptr<IObserver> loader) ORTHANC_OVERRIDE | |
67 { | |
68 that_.loaders_.push_back(loader); | |
69 } | |
70 | |
71 virtual void GetStatistics(uint64_t& scheduledCommands, | |
72 uint64_t& processedCommands) ORTHANC_OVERRIDE | |
73 { | |
74 scheduledCommands = that_.scheduler_->GetTotalScheduled(); | |
75 processedCommands = that_.scheduler_->GetTotalProcessed(); | |
76 } | |
77 }; | |
78 | |
79 | |
80 WebAssemblyLoadersContext::WebAssemblyLoadersContext(unsigned int maxHighPriority, | |
81 unsigned int maxStandardPriority, | |
82 unsigned int maxLowPriority) | |
83 { | |
84 oracle_.GetOracleObservable(); | |
85 scheduler_ = OracleScheduler::Create(oracle_, oracle_.GetOracleObservable(), oracle_, | |
86 maxHighPriority, maxStandardPriority, maxLowPriority); | |
87 | |
88 if (!scheduler_) | |
89 { | |
90 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
91 } | |
92 } | |
93 | |
94 | |
95 ILoadersContext::ILock* WebAssemblyLoadersContext::Lock() | |
96 { | |
97 return new Locker(*this); | |
98 } | |
99 } |