Better fatal error reporting

This commit is contained in:
emeric
2021-05-22 18:11:51 +02:00
parent 52447c0b56
commit 8e9f02edad
5 changed files with 64 additions and 7 deletions
+18 -2
View File
@@ -17,16 +17,32 @@
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "utils/Logger.hpp"
#include "utils/IOContextRunner.hpp"
#include <cstdlib>
#include "utils/Logger.hpp"
IOContextRunner::IOContextRunner(boost::asio::io_service& ioService, std::size_t threadCount)
: _ioService {ioService}
, _work {ioService}
{
LMS_LOG(UTILS, INFO) << "Starting IO Context with " << threadCount << " threads...";
for (std::size_t i {}; i < threadCount; ++i)
_threads.emplace_back([&] { _ioService.run(); });
{
_threads.emplace_back([&]
{
try
{
_ioService.run();
}
catch (const std::exception& e)
{
LMS_LOG(UTILS, FATAL) << "Exception caught in IO context: " << e.what();
std::abort();
}
});
}
}
void