ApplicationImpl::~ApplicationImpl()
{
    LOG(INFO) << "Application destructing";
    reportCfgMetrics();
    gracefulStop();
    joinAllThreads();
    LOG(INFO) << "Application destroyed";
}
void ThreadManager::joinAllThreads() {
	vector<future<void>>& threads = _threads.getVector<future<void>>();
	
	for (int i = 0; i < threads.size(); i++) {
		threads[i].wait();
		threads.erase(threads.begin() + i);
	}
	
	if (threads.size() > 0)
		joinAllThreads();
}
ApplicationImpl::~ApplicationImpl()
{
    LOG(INFO) << "Application destructing";
    if (mProcessManager)
    {
        mProcessManager->shutdown();
    }
    reportCfgMetrics();
    shutdownMainIOService();
    joinAllThreads();
    LOG(INFO) << "Application destroyed";
}