comparison Framework/Oracle/ThreadedOracle.cpp @ 1109:79b1b541fe15 broker

ThreadedOracle::SetRootDirectory()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 30 Oct 2019 11:56:10 +0100
parents 98cdfe5768a4
children a8bf81756839
comparison
equal deleted inserted replaced
1108:477203923f26 1109:79b1b541fe15
174 sleepingCommands_->Add(item.GetReceiver(), copy.release()); 174 sleepingCommands_->Add(item.GetReceiver(), copy.release());
175 } 175 }
176 else 176 else
177 { 177 {
178 GenericOracleRunner runner; 178 GenericOracleRunner runner;
179 runner.SetOrthanc(orthanc_); 179
180 {
181 boost::mutex::scoped_lock lock(mutex_);
182 runner.SetOrthanc(orthanc_);
183 runner.SetRootDirectory(rootDirectory_);
184 }
185
180 std::auto_ptr<IMessage> message(runner.Run(item.GetCommand())); 186 std::auto_ptr<IMessage> message(runner.Run(item.GetCommand()));
181 187
182 emitter_.EmitMessage(item.GetReceiver(), *message); 188 emitter_.EmitMessage(item.GetReceiver(), *message);
183 } 189 }
184 } 190 }
261 } 267 }
262 268
263 269
264 ThreadedOracle::ThreadedOracle(IMessageEmitter& emitter) : 270 ThreadedOracle::ThreadedOracle(IMessageEmitter& emitter) :
265 emitter_(emitter), 271 emitter_(emitter),
272 rootDirectory_("."),
266 state_(State_Setup), 273 state_(State_Setup),
267 workers_(4), 274 workers_(4),
268 sleepingCommands_(new SleepingCommands), 275 sleepingCommands_(new SleepingCommands),
269 sleepingTimeResolution_(50) // By default, time resolution of 50ms 276 sleepingTimeResolution_(50) // By default, time resolution of 50ms
270 { 277 {
295 302
296 303
297 void ThreadedOracle::SetOrthancParameters(const Orthanc::WebServiceParameters& orthanc) 304 void ThreadedOracle::SetOrthancParameters(const Orthanc::WebServiceParameters& orthanc)
298 { 305 {
299 boost::mutex::scoped_lock lock(mutex_); 306 boost::mutex::scoped_lock lock(mutex_);
300 307 orthanc_ = orthanc;
301 if (state_ != State_Setup) 308 }
302 { 309
303 LOG(ERROR) << "ThreadedOracle::SetOrthancParameters(): (state_ != State_Setup)"; 310
304 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); 311 void ThreadedOracle::SetRootDirectory(const std::string& rootDirectory)
305 } 312 {
306 else 313 boost::mutex::scoped_lock lock(mutex_);
307 { 314 rootDirectory_ = rootDirectory;
308 orthanc_ = orthanc;
309 }
310 } 315 }
311 316
312 317
313 void ThreadedOracle::SetThreadsCount(unsigned int count) 318 void ThreadedOracle::SetThreadsCount(unsigned int count)
314 { 319 {