Timed wait operations for spin-only Baton
[folly.git] / folly / synchronization / test / BatonTestHelpers.h
index 61b4e8c383a7bcab303dc58eeda9514828966ad0..0884927a79b2ab7113cc2b2f53be19d4df55f0d0 100644 (file)
@@ -53,17 +53,17 @@ void run_pingpong_test(int numRounds) {
   DSched::join(thr);
 }
 
   DSched::join(thr);
 }
 
-template <template <typename> class Atom, typename Clock>
+template <bool MayBlock, template <typename> class Atom, typename Clock>
 void run_basic_timed_wait_tests() {
 void run_basic_timed_wait_tests() {
-  Baton<true, Atom> b;
+  Baton<MayBlock, Atom> b;
   b.post();
   // tests if early delivery works fine
   EXPECT_TRUE(b.try_wait_until(Clock::now()));
 }
 
   b.post();
   // tests if early delivery works fine
   EXPECT_TRUE(b.try_wait_until(Clock::now()));
 }
 
-template <template <typename> class Atom, typename Clock>
+template <bool MayBlock, template <typename> class Atom, typename Clock>
 void run_timed_wait_tmo_tests() {
 void run_timed_wait_tmo_tests() {
-  Baton<true, Atom> b;
+  Baton<MayBlock, Atom> b;
 
   auto thr = DSched::thread([&] {
     bool rv = b.try_wait_until(Clock::now() + std::chrono::milliseconds(1));
 
   auto thr = DSched::thread([&] {
     bool rv = b.try_wait_until(Clock::now() + std::chrono::milliseconds(1));
@@ -73,9 +73,9 @@ void run_timed_wait_tmo_tests() {
   DSched::join(thr);
 }
 
   DSched::join(thr);
 }
 
-template <template <typename> class Atom, typename Clock>
+template <bool MayBlock, template <typename> class Atom, typename Clock>
 void run_timed_wait_regular_test() {
 void run_timed_wait_regular_test() {
-  Baton<true, Atom> b;
+  Baton<MayBlock, Atom> b;
 
   auto thr = DSched::thread([&] {
     // To wait forever we'd like to use time_point<Clock>::max, but
 
   auto thr = DSched::thread([&] {
     // To wait forever we'd like to use time_point<Clock>::max, but