Commit 5d2c7089 authored by Jakob Otto's avatar Jakob Otto

Synchronize test

parent f6f0b989
......@@ -174,20 +174,27 @@ CAF_TEST(send and receive) {
}
CAF_TEST(shutdown) {
auto run_mpx = [=] {
std::mutex m;
std::condition_variable cv;
bool thread_id_set = false;
auto run_mpx = [&] {
std::unique_lock<std::mutex> lk(m);
mpx->set_thread_id();
thread_id_set = true;
lk.unlock();
cv.notify_one();
mpx->run();
};
CAF_REQUIRE_EQUAL(mpx->init(), none);
std::thread mpx_thread{run_mpx};
auto sockets = unbox(make_stream_socket_pair());
auto alice = make_counted<dummy_manager>(manager_count, sockets.first, mpx);
auto bob = make_counted<dummy_manager>(manager_count, sockets.second, mpx);
alice->register_reading();
bob->register_reading();
while (mpx->num_socket_managers() != 3)
; // nop
CAF_REQUIRE_EQUAL(mpx->num_socket_managers(), 3u);
std::thread mpx_thread{run_mpx};
std::unique_lock<std::mutex> lk(m);
cv.wait(lk, [&] { return thread_id_set; });
mpx->shutdown();
mpx_thread.join();
CAF_REQUIRE_EQUAL(mpx->num_socket_managers(), 0u);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment