From 9cb500221e2d70d8bdba2f368e4d438c97a48a9e Mon Sep 17 00:00:00 2001 From: Maged Michael Date: Sat, 16 Dec 2017 17:20:04 -0800 Subject: [PATCH] Test UnboundedBlockingQueue in ThreadPoolExecutorTest Summary: Test UnboundedBlockingQueue for the case in D3527722 Reviewed By: ot Differential Revision: D6587163 fbshipit-source-id: 1465991018187c5f841e6e3e7a11676390e2f8f2 --- .../executors/test/ThreadPoolExecutorTest.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/folly/executors/test/ThreadPoolExecutorTest.cpp b/folly/executors/test/ThreadPoolExecutorTest.cpp index 3e9b68a2..a0fd9d12 100644 --- a/folly/executors/test/ThreadPoolExecutorTest.cpp +++ b/folly/executors/test/ThreadPoolExecutorTest.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -478,10 +479,11 @@ struct SlowMover { bool slow; }; -TEST(ThreadPoolExecutorTest, BugD3527722) { +template +void bugD3527722_test() { // Test that the queue does not get stuck if writes are completed in // order opposite to how they are initiated. - LifoSemMPMCQueue q(1024); + Q q(1024); std::atomic turn{}; std::thread consumer1([&] { @@ -515,6 +517,19 @@ TEST(ThreadPoolExecutorTest, BugD3527722) { consumer2.join(); } +TEST(ThreadPoolExecutorTest, LifoSemMPMCQueueBugD3527722) { + bugD3527722_test>(); +} + +template +struct UBQ : public UnboundedBlockingQueue { + explicit UBQ(int) {} +}; + +TEST(ThreadPoolExecutorTest, UnboundedBlockingQueueBugD3527722) { + bugD3527722_test>(); +} + template static void ShutdownTest() { // test that adding a .then() after we have -- 2.34.1