Refactor Application shutdown using new Service, AsyncService interfaces

This commit is contained in:
Vinnie Falco
2013-09-17 17:32:54 -07:00
parent 97e961a048
commit 89b1859929
57 changed files with 2690 additions and 1602 deletions

View File

@@ -28,7 +28,8 @@ public:
WSDoorImp (InfoSub::Source& source,
std::string const& strIp, int iPort, bool bPublic,
boost::asio::ssl::context& ssl_context)
: Thread ("websocket")
: WSDoor (source)
, Thread ("websocket")
, m_source (source)
, m_ssl_context (ssl_context)
, m_endpointLock (this, "WSDoor", __FILE__, __LINE__)
@@ -41,15 +42,7 @@ public:
~WSDoorImp ()
{
{
ScopedLockType lock (m_endpointLock, __FILE__, __LINE__);
if (m_endpoint != nullptr)
m_endpoint->stop ();
}
signalThreadShouldExit ();
waitForThreadToExit ();
stopThread ();
}
private:
@@ -101,6 +94,23 @@ private:
m_endpoint = nullptr;
}
serviceStopped ();
}
void onServiceStop ()
{
{
ScopedLockType lock (m_endpointLock, __FILE__, __LINE__);
// VFALCO NOTE we probably dont want to block here
// but websocketpp is deficient and broken.
//
if (m_endpoint != nullptr)
m_endpoint->stop ();
}
signalThreadShouldExit ();
}
private:
@@ -119,6 +129,13 @@ private:
//------------------------------------------------------------------------------
WSDoor::WSDoor (Service& parent)
: Service ("WSDoor", parent)
{
}
//------------------------------------------------------------------------------
WSDoor* WSDoor::New (InfoSub::Source& source, std::string const& strIp,
int iPort, bool bPublic, boost::asio::ssl::context& ssl_context)
{