Skip to content

Commit

Permalink
control of internal services lifetime moved from InternalAppContext i…
Browse files Browse the repository at this point in the history
…nto InternalApplication
  • Loading branch information
Pavel Kraynyukhov committed Jul 16, 2018
1 parent 080bbb1 commit 9cbe03d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
11 changes: 4 additions & 7 deletions include/InternalAppContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ namespace LAppS
{
class InternalAppContext : public ::abstract::ApplicationContext
{
public:
std::atomic<bool> mCanStop;
private:
std::atomic<bool> mMustStop;
std::atomic<bool> mCanStop;

const bool isInternalAppValid() const
{
bool ret=false;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -171,11 +173,6 @@ namespace LAppS
~InternalAppContext() noexcept
{
this->stop();
itc::sys::Nap waithere;
while(!mCanStop)
{
waithere.usleep(10000);
}
}
};
}
Expand Down
9 changes: 9 additions & 0 deletions include/InternalApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
};
Expand Down

0 comments on commit 9cbe03d

Please # to comment.