diff options
Diffstat (limited to 'base/base_tests/worker_thread_tests.cpp')
-rw-r--r-- | base/base_tests/worker_thread_tests.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/base/base_tests/worker_thread_tests.cpp b/base/base_tests/worker_thread_tests.cpp index be601e1540..309112bf00 100644 --- a/base/base_tests/worker_thread_tests.cpp +++ b/base/base_tests/worker_thread_tests.cpp @@ -3,6 +3,7 @@ #include "base/worker_thread.hpp" #include <condition_variable> +#include <future> #include <mutex> using namespace base; @@ -67,4 +68,22 @@ UNIT_TEST(WorkerThread_SimpleFlush) } TEST_EQUAL(value, 1024, ()); } + +UNIT_TEST(WorkerThread_PushFromPendingTask) +{ + // promise - future pair is used as a socketpair here to pass a + // signal from the main thread to the worker thread. + promise<void> p; + auto f = p.get_future(); + + WorkerThread thread; + bool const rv = thread.Push([&]() { + f.get(); + bool const rv = thread.Push([&]() { TEST(false, ("This task should not be executed")); }); + TEST(!rv, ()); + }); + TEST(rv, ()); + thread.Shutdown(WorkerThread::Exit::ExecPending); + p.set_value(); +} } // namespace |