#include #include #include #include using namespace drogon; struct TestCookie { TestCookie(std::shared_ptr ctx) : TEST_CTX(ctx) { } ~TestCookie() { if (!taken) FAIL("Test cookie not taken"); else SUCCESS(); } void take() { taken = true; } protected: bool taken = false; std::shared_ptr TEST_CTX; }; DROGON_TEST(MainLoopTest) { auto cookie = std::make_shared(TEST_CTX); drogon::app().getLoop()->queueInLoop([cookie]() { cookie->take(); }); std::thread t([TEST_CTX]() { auto cookie2 = std::make_shared(TEST_CTX); drogon::app().getLoop()->queueInLoop([cookie2]() { cookie2->take(); }); }); t.join(); }