Mercurial > hg > orthanc-stone
diff Applications/BasicApplicationContext.cpp @ 53:c2dc924f1a63 wasm
removing threading out of the framework
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 27 Apr 2017 16:57:49 +0200 |
parents | b340879da9bd |
children | d20e25cfcf3a |
line wrap: on
line diff
--- a/Applications/BasicApplicationContext.cpp Thu Apr 27 14:50:40 2017 +0200 +++ b/Applications/BasicApplicationContext.cpp Thu Apr 27 16:57:49 2017 +0200 @@ -27,8 +27,24 @@ namespace OrthancStone { + void BasicApplicationContext::UpdateThread(BasicApplicationContext* that) + { + while (!that->stopped_) + { + { + ViewportLocker locker(*that); + locker.GetViewport().UpdateContent(); + } + + boost::this_thread::sleep(boost::posix_time::milliseconds(that->updateDelay_)); + } + } + + BasicApplicationContext::BasicApplicationContext(OrthancPlugins::IOrthancConnection& orthanc) : - orthanc_(orthanc) + orthanc_(orthanc), + stopped_(true), + updateDelay_(100) // By default, 100ms between each refresh of the content { } @@ -119,11 +135,24 @@ } viewport_.Start(); + + if (viewport_.HasUpdateContent()) + { + stopped_ = false; + updateThread_ = boost::thread(UpdateThread, this); + } } void BasicApplicationContext::Stop() { + stopped_ = true; + + if (updateThread_.joinable()) + { + updateThread_.join(); + } + viewport_.Stop(); for (Volumes::iterator it = volumes_.begin(); it != volumes_.end(); ++it)