rcpp_framework/web_backends/drogon/trantor/tests/RunOnQuitTest.cc

28 lines
478 B
C++
Raw Normal View History

2022-02-10 01:24:36 +01:00
#include "core/loops/event_loop_thread.h"
2021-06-17 14:43:29 +02:00
#include <iostream>
#include <atomic>
#include <future>
#ifndef _WIN32
#include <unistd.h>
#endif
int main()
{
std::atomic<bool> flag(false);
{
trantor::EventLoopThread thr;
thr.getLoop()->runOnQuit([&]() { flag = true; });
thr.run();
thr.getLoop()->quit();
}
if (flag == false)
{
std::cerr << "Test failed\n";
}
else
{
std::cout << "Success\n";
}
}