Mercurial > hg > orthanc
annotate UnitTestsSources/MultiThreadingTests.cpp @ 1331:77e129ba64e4
Prevent freeze on C-FIND if no DICOM tag is to be returned
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 12 Mar 2015 10:47:32 +0100 |
parents | 7b6925b0890d |
children | ac4efabeb80c |
rev | line source |
---|---|
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
1 /** |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1009
diff
changeset
|
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics |
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1009
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
5 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
9 * License, or (at your option) any later version. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
10 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
11 * In addition, as a special exception, the copyright holders of this |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
12 * program give permission to link the code of its release with the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
14 * that use the same license as the "OpenSSL" library), and distribute |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
15 * the linked executables. You must obey the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
16 * in all respects for all of the code used other than "OpenSSL". If you |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
17 * modify file(s) with this exception, you may extend this exception to |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
18 * your version of the file(s), but you are not obligated to do so. If |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
19 * you do not wish to do so, delete this exception statement from your |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
20 * version. If you delete this exception statement from all source files |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
21 * in the program, then also delete it here. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
22 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
23 * This program is distributed in the hope that it will be useful, but |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
24 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
26 * General Public License for more details. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
27 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
28 * You should have received a copy of the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
30 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
31 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
776
diff
changeset
|
32 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
827
diff
changeset
|
33 #include "PrecompiledHeadersUnitTests.h" |
723 | 34 #include "gtest/gtest.h" |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
35 #include <glog/logging.h> |
723 | 36 |
781 | 37 #include "../OrthancServer/Scheduler/ServerScheduler.h" |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
38 |
723 | 39 #include "../Core/OrthancException.h" |
40 #include "../Core/Toolbox.h" | |
41 #include "../Core/MultiThreading/ArrayFilledByThreads.h" | |
760 | 42 #include "../Core/MultiThreading/Locker.h" |
43 #include "../Core/MultiThreading/Mutex.h" | |
44 #include "../Core/MultiThreading/ReaderWriterLock.h" | |
723 | 45 #include "../Core/MultiThreading/ThreadedCommandProcessor.h" |
46 | |
47 using namespace Orthanc; | |
48 | |
49 namespace | |
50 { | |
51 class DynamicInteger : public ICommand | |
52 { | |
53 private: | |
54 int value_; | |
55 std::set<int>& target_; | |
56 | |
57 public: | |
58 DynamicInteger(int value, std::set<int>& target) : | |
59 value_(value), target_(target) | |
60 { | |
61 } | |
62 | |
63 int GetValue() const | |
64 { | |
65 return value_; | |
66 } | |
67 | |
68 virtual bool Execute() | |
69 { | |
70 static boost::mutex mutex; | |
71 boost::mutex::scoped_lock lock(mutex); | |
72 target_.insert(value_); | |
73 return true; | |
74 } | |
75 }; | |
76 | |
77 class MyFiller : public ArrayFilledByThreads::IFiller | |
78 { | |
79 private: | |
80 int size_; | |
81 unsigned int created_; | |
82 std::set<int> set_; | |
83 | |
84 public: | |
85 MyFiller(int size) : size_(size), created_(0) | |
86 { | |
87 } | |
88 | |
89 virtual size_t GetFillerSize() | |
90 { | |
91 return size_; | |
92 } | |
93 | |
94 virtual IDynamicObject* GetFillerItem(size_t index) | |
95 { | |
96 static boost::mutex mutex; | |
97 boost::mutex::scoped_lock lock(mutex); | |
98 created_++; | |
99 return new DynamicInteger(index * 2, set_); | |
100 } | |
101 | |
102 unsigned int GetCreatedCount() const | |
103 { | |
104 return created_; | |
105 } | |
106 | |
107 std::set<int> GetSet() | |
108 { | |
109 return set_; | |
110 } | |
111 }; | |
112 } | |
113 | |
114 | |
115 | |
116 | |
117 TEST(MultiThreading, SharedMessageQueueBasic) | |
118 { | |
119 std::set<int> s; | |
120 | |
121 SharedMessageQueue q; | |
122 ASSERT_TRUE(q.WaitEmpty(0)); | |
123 q.Enqueue(new DynamicInteger(10, s)); | |
124 ASSERT_FALSE(q.WaitEmpty(1)); | |
125 q.Enqueue(new DynamicInteger(20, s)); | |
126 q.Enqueue(new DynamicInteger(30, s)); | |
127 q.Enqueue(new DynamicInteger(40, s)); | |
128 | |
129 std::auto_ptr<DynamicInteger> i; | |
130 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(10, i->GetValue()); | |
131 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(20, i->GetValue()); | |
132 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(30, i->GetValue()); | |
133 ASSERT_FALSE(q.WaitEmpty(1)); | |
134 i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(40, i->GetValue()); | |
135 ASSERT_TRUE(q.WaitEmpty(0)); | |
136 ASSERT_EQ(NULL, q.Dequeue(1)); | |
137 } | |
138 | |
139 | |
140 TEST(MultiThreading, SharedMessageQueueClean) | |
141 { | |
142 std::set<int> s; | |
143 | |
144 try | |
145 { | |
146 SharedMessageQueue q; | |
147 q.Enqueue(new DynamicInteger(10, s)); | |
148 q.Enqueue(new DynamicInteger(20, s)); | |
149 throw OrthancException("Nope"); | |
150 } | |
151 catch (OrthancException&) | |
152 { | |
153 } | |
154 } | |
155 | |
156 | |
157 TEST(MultiThreading, ArrayFilledByThreadEmpty) | |
158 { | |
159 MyFiller f(0); | |
160 ArrayFilledByThreads a(f); | |
161 a.SetThreadCount(1); | |
162 ASSERT_EQ(0, a.GetSize()); | |
163 } | |
164 | |
165 | |
166 TEST(MultiThreading, ArrayFilledByThread1) | |
167 { | |
168 MyFiller f(100); | |
169 ArrayFilledByThreads a(f); | |
170 a.SetThreadCount(1); | |
171 ASSERT_EQ(100, a.GetSize()); | |
172 for (size_t i = 0; i < a.GetSize(); i++) | |
173 { | |
174 ASSERT_EQ(2 * i, dynamic_cast<DynamicInteger&>(a.GetItem(i)).GetValue()); | |
175 } | |
176 } | |
177 | |
178 | |
179 TEST(MultiThreading, ArrayFilledByThread4) | |
180 { | |
181 MyFiller f(100); | |
182 ArrayFilledByThreads a(f); | |
183 a.SetThreadCount(4); | |
184 ASSERT_EQ(100, a.GetSize()); | |
185 for (size_t i = 0; i < a.GetSize(); i++) | |
186 { | |
187 ASSERT_EQ(2 * i, dynamic_cast<DynamicInteger&>(a.GetItem(i)).GetValue()); | |
188 } | |
189 | |
190 ASSERT_EQ(100u, f.GetCreatedCount()); | |
191 | |
192 a.Invalidate(); | |
193 | |
194 ASSERT_EQ(100, a.GetSize()); | |
195 ASSERT_EQ(200u, f.GetCreatedCount()); | |
196 ASSERT_EQ(4u, a.GetThreadCount()); | |
197 ASSERT_TRUE(f.GetSet().empty()); | |
198 | |
199 for (size_t i = 0; i < a.GetSize(); i++) | |
200 { | |
201 ASSERT_EQ(2 * i, dynamic_cast<DynamicInteger&>(a.GetItem(i)).GetValue()); | |
202 } | |
203 } | |
204 | |
205 | |
206 TEST(MultiThreading, CommandProcessor) | |
207 { | |
208 ThreadedCommandProcessor p(4); | |
209 | |
210 std::set<int> s; | |
211 | |
212 for (size_t i = 0; i < 100; i++) | |
213 { | |
214 p.Post(new DynamicInteger(i * 2, s)); | |
215 } | |
216 | |
217 p.Join(); | |
218 | |
219 for (size_t i = 0; i < 200; i++) | |
220 { | |
221 if (i % 2) | |
222 ASSERT_TRUE(s.find(i) == s.end()); | |
223 else | |
224 ASSERT_TRUE(s.find(i) != s.end()); | |
225 } | |
226 } | |
760 | 227 |
228 | |
229 TEST(MultiThreading, Mutex) | |
230 { | |
231 Mutex mutex; | |
232 Locker locker(mutex); | |
233 } | |
234 | |
235 | |
236 TEST(MultiThreading, ReaderWriterLock) | |
237 { | |
238 ReaderWriterLock lock; | |
239 | |
240 { | |
241 Locker locker1(lock.ForReader()); | |
242 Locker locker2(lock.ForReader()); | |
243 } | |
244 | |
245 { | |
246 Locker locker3(lock.ForWriter()); | |
247 } | |
248 } | |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
249 |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
250 |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
251 |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
252 #include "../OrthancServer/DicomProtocol/ReusableDicomUserConnection.h" |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
253 |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
254 TEST(ReusableDicomUserConnection, DISABLED_Basic) |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
255 { |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
256 ReusableDicomUserConnection c; |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
257 c.SetMillisecondsBeforeClose(200); |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
258 printf("START\n"); fflush(stdout); |
775
d3ba35466225
integration mainline -> lua-scripting
Sebastien Jodogne <s.jodogne@gmail.com>
diff
changeset
|
259 |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
260 { |
776 | 261 ReusableDicomUserConnection::Locker lock(c, "STORESCP", "localhost", 2000, ModalityManufacturer_Generic); |
262 lock.GetConnection().StoreFile("/home/jodogne/DICOM/Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386844.676281"); | |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
263 } |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
264 |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
265 printf("**\n"); fflush(stdout); |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
266 Toolbox::USleep(1000000); |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
267 printf("**\n"); fflush(stdout); |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
268 |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
269 { |
776 | 270 ReusableDicomUserConnection::Locker lock(c, "STORESCP", "localhost", 2000, ModalityManufacturer_Generic); |
271 lock.GetConnection().StoreFile("/home/jodogne/DICOM/Cardiac/MR.X.1.2.276.0.7230010.3.1.4.2831157719.2256.1336386844.676277"); | |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
272 } |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
273 |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
274 Toolbox::ServerBarrier(); |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
275 printf("DONE\n"); fflush(stdout); |
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
760
diff
changeset
|
276 } |
765 | 277 |
278 | |
279 | |
1000
13e230bbd882
rename filter to command
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
995
diff
changeset
|
280 class Tutu : public IServerCommand |
765 | 281 { |
282 private: | |
283 int factor_; | |
284 | |
285 public: | |
286 Tutu(int f) : factor_(f) | |
287 { | |
288 } | |
289 | |
290 virtual bool Apply(ListOfStrings& outputs, | |
291 const ListOfStrings& inputs) | |
292 { | |
293 for (ListOfStrings::const_iterator | |
1304 | 294 it = inputs.begin(); it != inputs.end(); ++it) |
765 | 295 { |
296 int a = boost::lexical_cast<int>(*it); | |
297 int b = factor_ * a; | |
298 | |
299 printf("%d * %d = %d\n", a, factor_, b); | |
300 | |
301 //if (a == 84) { printf("BREAK\n"); return false; } | |
302 | |
303 outputs.push_back(boost::lexical_cast<std::string>(b)); | |
304 } | |
305 | |
1009
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
306 Toolbox::USleep(100000); |
765 | 307 |
308 return true; | |
309 } | |
310 }; | |
311 | |
768 | 312 |
770 | 313 static void Tata(ServerScheduler* s, ServerJob* j, bool* done) |
768 | 314 { |
1000
13e230bbd882
rename filter to command
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
995
diff
changeset
|
315 typedef IServerCommand::ListOfStrings ListOfStrings; |
779 | 316 |
770 | 317 while (!(*done)) |
768 | 318 { |
319 ListOfStrings l; | |
320 s->GetListOfJobs(l); | |
1304 | 321 for (ListOfStrings::iterator it = l.begin(); it != l.end(); ++it) |
322 { | |
323 printf(">> %s: %0.1f\n", it->c_str(), 100.0f * s->GetProgress(*it)); | |
324 } | |
1009
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
325 Toolbox::USleep(10000); |
768 | 326 } |
327 } | |
328 | |
329 | |
1009
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
330 TEST(MultiThreading, ServerScheduler) |
765 | 331 { |
995
8c67382f44a7
limit number of jobs in the scheduler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
994
diff
changeset
|
332 ServerScheduler scheduler(10); |
765 | 333 |
334 ServerJob job; | |
1000
13e230bbd882
rename filter to command
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
995
diff
changeset
|
335 ServerCommandInstance& f2 = job.AddCommand(new Tutu(2)); |
13e230bbd882
rename filter to command
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
995
diff
changeset
|
336 ServerCommandInstance& f3 = job.AddCommand(new Tutu(3)); |
13e230bbd882
rename filter to command
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
995
diff
changeset
|
337 ServerCommandInstance& f4 = job.AddCommand(new Tutu(4)); |
13e230bbd882
rename filter to command
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
995
diff
changeset
|
338 ServerCommandInstance& f5 = job.AddCommand(new Tutu(5)); |
765 | 339 f2.AddInput(boost::lexical_cast<std::string>(42)); |
340 //f3.AddInput(boost::lexical_cast<std::string>(42)); | |
341 //f4.AddInput(boost::lexical_cast<std::string>(42)); | |
1009
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
342 f2.ConnectOutput(f3); |
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
343 f3.ConnectOutput(f4); |
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
344 f4.ConnectOutput(f5); |
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
345 |
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
346 f3.SetConnectedToSink(true); |
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
347 f5.SetConnectedToSink(true); |
765 | 348 |
349 job.SetDescription("tutu"); | |
350 | |
770 | 351 bool done = false; |
352 boost::thread t(Tata, &scheduler, &job, &done); | |
768 | 353 |
354 | |
765 | 355 //scheduler.Submit(job); |
356 | |
1000
13e230bbd882
rename filter to command
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
995
diff
changeset
|
357 IServerCommand::ListOfStrings l; |
765 | 358 scheduler.SubmitAndWait(l, job); |
359 | |
1009
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
360 ASSERT_EQ(2, l.size()); |
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
361 ASSERT_EQ(42 * 2 * 3, boost::lexical_cast<int>(l.front())); |
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
362 ASSERT_EQ(42 * 2 * 3 * 4 * 5, boost::lexical_cast<int>(l.back())); |
26642cecd36d
clearer job interface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1005
diff
changeset
|
363 |
1000
13e230bbd882
rename filter to command
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
995
diff
changeset
|
364 for (IServerCommand::ListOfStrings::iterator i = l.begin(); i != l.end(); i++) |
765 | 365 { |
366 printf("** %s\n", i->c_str()); | |
367 } | |
368 | |
369 //Toolbox::ServerBarrier(); | |
768 | 370 //Toolbox::USleep(3000000); |
371 | |
770 | 372 done = true; |
373 t.join(); | |
765 | 374 } |