comparison Applications/ApplicationToolbox.cpp @ 236:b0ee417b667a

migrating new definitions in namespace Orthanc to namespace OrthancWSI
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 23 Feb 2021 10:27:58 +0100
parents 1e864138f0da
children 49f647ed1b4c
comparison
equal deleted inserted replaced
235:8a5b2b068e52 236:b0ee417b667a
78 Orthanc::HttpClient::GlobalFinalize(); 78 Orthanc::HttpClient::GlobalFinalize();
79 Orthanc::Toolbox::FinalizeOpenSsl(); 79 Orthanc::Toolbox::FinalizeOpenSsl();
80 } 80 }
81 81
82 82
83 static void PrintProgress(Orthanc::BagOfTasksProcessor::Handle* handle, 83 static void PrintProgress(BagOfTasksProcessor::Handle* handle,
84 bool* done) 84 bool* done)
85 { 85 {
86 unsigned int previous = 0; 86 unsigned int previous = 0;
87 87
88 while (!*done) 88 while (!*done)
97 boost::this_thread::sleep(boost::posix_time::milliseconds(100)); 97 boost::this_thread::sleep(boost::posix_time::milliseconds(100));
98 } 98 }
99 } 99 }
100 100
101 101
102 void Execute(Orthanc::BagOfTasks& tasks, 102 void Execute(BagOfTasks& tasks,
103 unsigned int threadsCount) 103 unsigned int threadsCount)
104 { 104 {
105 if (threadsCount > 1) 105 if (threadsCount > 1)
106 { 106 {
107 // Submit the tasks to a newly-created processor 107 // Submit the tasks to a newly-created processor
108 LOG(WARNING) << "Running " << tasks.GetSize() << " tasks"; 108 LOG(WARNING) << "Running " << tasks.GetSize() << " tasks";
109 LOG(WARNING) << "Using " << threadsCount << " threads for the computation"; 109 LOG(WARNING) << "Using " << threadsCount << " threads for the computation";
110 Orthanc::BagOfTasksProcessor processor(threadsCount); 110 BagOfTasksProcessor processor(threadsCount);
111 std::unique_ptr<Orthanc::BagOfTasksProcessor::Handle> handle(processor.Submit(tasks)); 111 std::unique_ptr<BagOfTasksProcessor::Handle> handle(processor.Submit(tasks));
112 112
113 // Start a thread to display the progress 113 // Start a thread to display the progress
114 bool done = false; 114 bool done = false;
115 boost::thread progress(PrintProgress, handle.get(), &done); 115 boost::thread progress(PrintProgress, handle.get(), &done);
116 116
143 unsigned int size = tasks.GetSize(); 143 unsigned int size = tasks.GetSize();
144 144
145 // No multithreading 145 // No multithreading
146 while (!tasks.IsEmpty()) 146 while (!tasks.IsEmpty())
147 { 147 {
148 std::unique_ptr<Orthanc::ICommand> task(tasks.Pop()); 148 std::unique_ptr<ICommand> task(tasks.Pop());
149 if (task->Execute()) 149 if (task->Execute())
150 { 150 {
151 unsigned int progress = static_cast<unsigned int>(100.0f * 151 unsigned int progress = static_cast<unsigned int>(100.0f *
152 static_cast<float>((size - tasks.GetSize())) / 152 static_cast<float>((size - tasks.GetSize())) /
153 static_cast<float>(size)); 153 static_cast<float>(size));