Mercurial > hg > orthanc-client
comparison CppClient/ArrayFilledByThreads.cpp @ 6:c584c25a74fd
cont
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 02 Jun 2015 10:22:49 +0200 |
parents | 798076adf9e9 |
children | e59bf2554e59 |
comparison
equal
deleted
inserted
replaced
5:798076adf9e9 | 6:c584c25a74fd |
---|---|
33 #include "ArrayFilledByThreads.h" | 33 #include "ArrayFilledByThreads.h" |
34 | 34 |
35 #include "ThreadedCommandProcessor.h" | 35 #include "ThreadedCommandProcessor.h" |
36 #include "../Orthanc/Core/OrthancException.h" | 36 #include "../Orthanc/Core/OrthancException.h" |
37 | 37 |
38 namespace Orthanc | 38 namespace OrthancClient |
39 { | 39 { |
40 class ArrayFilledByThreads::Command : public ICommand | 40 class ArrayFilledByThreads::Command : public Orthanc::ICommand |
41 { | 41 { |
42 private: | 42 private: |
43 ArrayFilledByThreads& that_; | 43 ArrayFilledByThreads& that_; |
44 size_t index_; | 44 size_t index_; |
45 | 45 |
83 { | 83 { |
84 if (!filled_) | 84 if (!filled_) |
85 { | 85 { |
86 array_.resize(filler_.GetFillerSize()); | 86 array_.resize(filler_.GetFillerSize()); |
87 | 87 |
88 Orthanc::ThreadedCommandProcessor processor(threadCount_); | 88 ThreadedCommandProcessor processor(threadCount_); |
89 for (size_t i = 0; i < array_.size(); i++) | 89 for (size_t i = 0; i < array_.size(); i++) |
90 { | 90 { |
91 processor.Post(new Command(*this, i)); | 91 processor.Post(new Command(*this, i)); |
92 } | 92 } |
93 | 93 |
125 | 125 |
126 void ArrayFilledByThreads::SetThreadCount(unsigned int t) | 126 void ArrayFilledByThreads::SetThreadCount(unsigned int t) |
127 { | 127 { |
128 if (t < 1) | 128 if (t < 1) |
129 { | 129 { |
130 throw OrthancException(ErrorCode_ParameterOutOfRange); | 130 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
131 } | 131 } |
132 | 132 |
133 threadCount_ = t; | 133 threadCount_ = t; |
134 } | 134 } |
135 | 135 |
139 Update(); | 139 Update(); |
140 return array_.size(); | 140 return array_.size(); |
141 } | 141 } |
142 | 142 |
143 | 143 |
144 IDynamicObject& ArrayFilledByThreads::GetItem(size_t index) | 144 Orthanc::IDynamicObject& ArrayFilledByThreads::GetItem(size_t index) |
145 { | 145 { |
146 if (index >= GetSize()) | 146 if (index >= GetSize()) |
147 { | 147 { |
148 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 148 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
149 } | 149 } |