comparison OrthancServer/Sources/ServerContext.cpp @ 5182:cddf28cfcd8d

style
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 25 Mar 2023 11:38:37 +0100
parents 65b05b44ae4c
children 5ec3dcdf78b9
comparison
equal deleted inserted replaced
5181:65b05b44ae4c 5182:cddf28cfcd8d
105 status_(StoreStatus_Failure), 105 status_(StoreStatus_Failure),
106 cstoreStatusCode_(0) 106 cstoreStatusCode_(0)
107 { 107 {
108 } 108 }
109 109
110
111 #if HAVE_MALLOC_TRIM == 1
110 void ServerContext::HousekeeperThread(ServerContext* that, 112 void ServerContext::HousekeeperThread(ServerContext* that,
111 unsigned int sleepDelay) 113 unsigned int sleepDelay)
112 { 114 {
113 // note, right now, this thread is started only if malloc_trim is defined 115 // note, right now, this thread is started only if malloc_trim is defined
114 while (!that->done_) 116 while (!that->done_)
115 { 117 {
116 boost::this_thread::sleep(boost::posix_time::milliseconds(sleepDelay)); 118 boost::this_thread::sleep(boost::posix_time::milliseconds(sleepDelay));
117 119
118 // If possible, gives memory back to the system 120 // If possible, gives memory back to the system
119 // (see OrthancServer/Resources/ImplementationNotes/memory_consumption.txt) 121 // (see OrthancServer/Resources/ImplementationNotes/memory_consumption.txt)
120 #if HAVE_MALLOC_TRIM == 1
121 malloc_trim(128*1024); 122 malloc_trim(128*1024);
123 }
124 }
122 #endif 125 #endif
123 } 126
124 }
125 127
126 void ServerContext::ChangeThread(ServerContext* that, 128 void ServerContext::ChangeThread(ServerContext* that,
127 unsigned int sleepDelay) 129 unsigned int sleepDelay)
128 { 130 {
129 while (!that->done_) 131 while (!that->done_)
433 435
434 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200); 436 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200);
435 437
436 listeners_.push_back(ServerListener(luaListener_, "Lua")); 438 listeners_.push_back(ServerListener(luaListener_, "Lua"));
437 changeThread_ = boost::thread(ChangeThread, this, (unitTesting ? 20 : 100)); 439 changeThread_ = boost::thread(ChangeThread, this, (unitTesting ? 20 : 100));
440
438 #if HAVE_MALLOC_TRIM == 1 441 #if HAVE_MALLOC_TRIM == 1
439 housekeeperThread_ = boost::thread(HousekeeperThread, this, 1000); 442 housekeeperThread_ = boost::thread(HousekeeperThread, this, 100);
440 #else 443 #else
441 LOG(INFO) << "Your platform does not support malloc_trim(), not starting the housekeeper thread"; 444 LOG(INFO) << "Your platform does not support malloc_trim(), not starting the housekeeper thread";
442 #endif 445 #endif
446
443 dynamic_cast<DcmtkTranscoder&>(*dcmtkTranscoder_).SetLossyQuality(lossyQuality); 447 dynamic_cast<DcmtkTranscoder&>(*dcmtkTranscoder_).SetLossyQuality(lossyQuality);
444 } 448 }
445 catch (OrthancException&) 449 catch (OrthancException&)
446 { 450 {
447 Stop(); 451 Stop();