Modify the quit() method (#276)
This commit is contained in:
parent
df82728a45
commit
8f5c757ce2
|
@ -756,4 +756,12 @@ HttpAppFramework &HttpAppFrameworkImpl::createDbClient(
|
|||
name,
|
||||
isFast);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void HttpAppFrameworkImpl::quit()
|
||||
{
|
||||
if (getLoop()->isRunning())
|
||||
{
|
||||
getLoop()->queueInLoop([this]() { getLoop()->quit(); });
|
||||
}
|
||||
}
|
|
@ -317,11 +317,7 @@ class HttpAppFrameworkImpl : public HttpAppFramework
|
|||
|
||||
virtual trantor::EventLoop *getLoop() const override;
|
||||
|
||||
virtual void quit() override
|
||||
{
|
||||
if (getLoop()->isRunning())
|
||||
getLoop()->quit();
|
||||
}
|
||||
virtual void quit() override;
|
||||
|
||||
virtual HttpAppFramework &setServerHeaderField(
|
||||
const std::string &server) override
|
||||
|
|
|
@ -191,3 +191,17 @@ void ListenerManager::startListening()
|
|||
loopThread->run();
|
||||
}
|
||||
}
|
||||
|
||||
ListenerManager::~ListenerManager()
|
||||
{
|
||||
for (size_t i = 0; i < _servers.size(); ++i)
|
||||
{
|
||||
std::promise<int> pro;
|
||||
auto f = pro.get_future();
|
||||
_servers[i]->getLoop()->runInLoop([&pro, this, i] {
|
||||
_servers[i].reset();
|
||||
pro.set_value(1);
|
||||
});
|
||||
(void)f.get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ class ListenerManager : public trantor::NonCopyable
|
|||
std::function<HttpResponsePtr(const HttpRequestPtr &)>>
|
||||
&syncAdvices);
|
||||
void startListening();
|
||||
~ListenerManager();
|
||||
|
||||
private:
|
||||
struct ListenerInfo
|
||||
|
|
Loading…
Reference in New Issue