annotate Framework/Loaders/WebAssemblyLoadersContext.cpp @ 1444:687457d4018f loader-injection-feature

Getter for slice processor
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 26 May 2020 12:11:18 +0200
parents 0ca50d275b9a
children 474360793956
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1248
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1271
0ca50d275b9a upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1248
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
1248
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include "WebAssemblyLoadersContext.h"
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 namespace OrthancStone
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 class WebAssemblyLoadersContext::Locker : public ILoadersContext::ILock
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 private:
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 WebAssemblyLoadersContext& that_;
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 public:
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 Locker(WebAssemblyLoadersContext& that) :
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 that_(that)
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 }
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 virtual ILoadersContext& GetContext() const ORTHANC_OVERRIDE
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 return that_;
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 }
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 virtual IObservable& GetOracleObservable() const ORTHANC_OVERRIDE
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 return that_.oracle_.GetOracleObservable();
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 }
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 virtual void Schedule(boost::shared_ptr<IObserver> receiver,
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 int priority,
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 IOracleCommand* command /* Takes ownership */) ORTHANC_OVERRIDE
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 that_.scheduler_->Schedule(receiver, priority, command);
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 }
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 virtual void CancelRequests(boost::shared_ptr<IObserver> receiver) ORTHANC_OVERRIDE
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 that_.scheduler_->CancelRequests(receiver);
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 virtual void CancelAllRequests() ORTHANC_OVERRIDE
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 that_.scheduler_->CancelAllRequests();
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 }
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 virtual void AddLoader(boost::shared_ptr<IObserver> loader) ORTHANC_OVERRIDE
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 that_.loaders_.push_back(loader);
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 }
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 virtual void GetStatistics(uint64_t& scheduledCommands,
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 uint64_t& processedCommands) ORTHANC_OVERRIDE
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 scheduledCommands = that_.scheduler_->GetTotalScheduled();
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 processedCommands = that_.scheduler_->GetTotalProcessed();
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 }
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 };
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 WebAssemblyLoadersContext::WebAssemblyLoadersContext(unsigned int maxHighPriority,
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 unsigned int maxStandardPriority,
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 unsigned int maxLowPriority)
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 scheduler_ = OracleScheduler::Create(oracle_, oracle_.GetOracleObservable(), oracle_,
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 maxHighPriority, maxStandardPriority, maxLowPriority);
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 if (!scheduler_)
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 }
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 }
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 ILoadersContext::ILock* WebAssemblyLoadersContext::Lock()
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 {
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 return new Locker(*this);
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 }
2a8359503f3b WebAssemblyLoadersContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 }