Mercurial > hg > orthanc
diff Core/Toolbox.cpp @ 1101:e5686a703c63
ServerBarrier with external stop condition
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 07 Aug 2014 10:21:43 +0200 |
parents | e494ceb8d763 |
children | ce6386b37afd |
line wrap: on
line diff
--- a/Core/Toolbox.cpp Thu Aug 07 10:11:43 2014 +0200 +++ b/Core/Toolbox.cpp Thu Aug 07 10:21:43 2014 +0200 @@ -124,7 +124,7 @@ } - void Toolbox::ServerBarrier() + static void ServerBarrierInternal(bool* stopFlag) { #if defined(_WIN32) SetConsoleCtrlHandler(ConsoleControlHandler, true); @@ -134,10 +134,11 @@ signal(SIGTERM, SignalHandler); #endif + // Active loop that awakens every 100ms finish = false; - while (!finish) + while (!(*stopFlag || finish)) { - USleep(100000); + Toolbox::USleep(100 * 1000); } #if defined(_WIN32) @@ -150,6 +151,17 @@ } + void Toolbox::ServerBarrier(bool& stopFlag) + { + ServerBarrierInternal(&stopFlag); + } + + void Toolbox::ServerBarrier() + { + bool stopFlag = false; + ServerBarrierInternal(&stopFlag); + } + void Toolbox::ToUpperCase(std::string& s) {