From 9cbe03d4172bf0056e2d9babebed37a54b78ec6e Mon Sep 17 00:00:00 2001 From: Pavel Kraynyukhov Date: Tue, 17 Jul 2018 03:16:54 +0600 Subject: [PATCH] control of internal services lifetime moved from InternalAppContext into InternalApplication --- include/InternalAppContext.h | 11 ++++------- include/InternalApplication.h | 9 +++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/InternalAppContext.h b/include/InternalAppContext.h index 31454ec..e93764f 100644 --- a/include/InternalAppContext.h +++ b/include/InternalAppContext.h @@ -62,9 +62,11 @@ namespace LAppS { class InternalAppContext : public ::abstract::ApplicationContext { + public: + std::atomic mCanStop; private: std::atomic mMustStop; - std::atomic mCanStop; + const bool isInternalAppValid() const { bool ret=false; @@ -96,7 +98,7 @@ namespace LAppS public: InternalAppContext(const std::string& name): - ::abstract::ApplicationContext(name), mMustStop{false},mCanStop{false} + ::abstract::ApplicationContext(name), mCanStop{false}, mMustStop{false} { luaL_openlibs(mLState); @@ -171,11 +173,6 @@ namespace LAppS ~InternalAppContext() noexcept { this->stop(); - itc::sys::Nap waithere; - while(!mCanStop) - { - waithere.usleep(10000); - } } }; } diff --git a/include/InternalApplication.h b/include/InternalApplication.h index e007e04..445d333 100644 --- a/include/InternalApplication.h +++ b/include/InternalApplication.h @@ -72,7 +72,16 @@ namespace LAppS } void shutdown() { + itc::getLog()->info(__FILE__,__LINE__,"Shutdown is requested for an instance %ul of the internal application %s",mInstanceID, mContext.getName().c_str()); mContext.stop(); + + itc::sys::Nap waithere; + + while(!mContext.mCanStop.load()) + { + waithere.usleep(10000); + } + itc::getLog()->info(__FILE__,__LINE__,"Instance %ul of an internal application %s is down",mInstanceID, mContext.getName().c_str()); } };