]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/fiber/test/test_fiber_dispatch.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / fiber / test / test_fiber_dispatch.cpp
index cbba2fb2494867ccb43facc0e6f5784a5bcd4e35..458fe4eaf90fbe6eac52e7216ebf470ed4153bb5 100644 (file)
@@ -178,7 +178,7 @@ void test_join_fn() {
 void test_join_memfn() {
     X x = {0};
     BOOST_CHECK_EQUAL( x.value, 0);
-    boost::fibers::fiber( boost::fibers::launch::dispatch, & X::foo, std::ref( x), 3).join();
+    boost::fibers::fiber( boost::fibers::launch::dispatch, & X::foo, & x, 3).join();
     BOOST_CHECK_EQUAL( x.value, 3);
 }
 
@@ -256,41 +256,36 @@ void test_join_bind() {
     {
         value1 = 0;
         value2 = "";
-        int i = 3;
         std::string abc("abc");
         boost::fibers::fiber f(
             boost::fibers::launch::dispatch, std::bind(
-                []( int i, std::string & str) {
+                [](std::string & str) {
                     value1 = 3;
                     value2 = str;
                 },
-                i, abc
+                abc
             ));
         f.join();
         BOOST_CHECK_EQUAL( value1, 3);
         BOOST_CHECK_EQUAL( value2, "abc");
     }
-#if 0
     {
         value1 = 0;
         value2 = "";
-        int i = 3;
         std::string abc("abc");
         boost::fibers::fiber f(
             boost::fibers::launch::dispatch, std::bind(
-                []( int i, std::string & str) {
+                []( std::string & str) {
                     value1 = 3;
                     value2 = str;
                 },
-                std::placeholders::_1,
-                std::placeholders::_2
+                std::placeholders::_1
             ),
-            i, abc);
+            std::ref( abc) );
         f.join();
         BOOST_CHECK_EQUAL( value1, 3);
         BOOST_CHECK_EQUAL( value2, "abc");
     }
-#endif
 }
 
 void test_join_in_fiber() {
@@ -365,11 +360,9 @@ void test_sleep_for() {
     boost::this_fiber::sleep_for(ms);
     time_point t1 = Clock::now();
     std::chrono::nanoseconds ns = (t1 - t0) - ms;
-    std::chrono::nanoseconds err = ms / 100;
-    // The time slept is within 1% of 500ms
+    std::chrono::nanoseconds err = ms / 10;
     // This test is spurious as it depends on the time the fiber system switches the fiber
     BOOST_CHECK((std::max)(ns.count(), -ns.count()) < (err+std::chrono::milliseconds(1000)).count());
-    //BOOST_TEST(std::abs(static_cast<long>(ns.count())) < (err+std::chrono::milliseconds(1000)).count());
 }
 
 void test_sleep_until() {
@@ -381,11 +374,9 @@ void test_sleep_until() {
         boost::this_fiber::sleep_until(t0 + ms);
         time_point t1 = Clock::now();
         std::chrono::nanoseconds ns = (t1 - t0) - ms;
-        std::chrono::nanoseconds err = ms / 100;
-        // The time slept is within 1% of 500ms
+        std::chrono::nanoseconds err = ms / 10;
         // This test is spurious as it depends on the time the thread system switches the threads
         BOOST_CHECK((std::max)(ns.count(), -ns.count()) < (err+std::chrono::milliseconds(1000)).count());
-        //BOOST_TEST(std::abs(static_cast<long>(ns.count())) < (err+std::chrono::milliseconds(1000)).count());
     }
     {
         typedef std::chrono::system_clock Clock;
@@ -395,11 +386,9 @@ void test_sleep_until() {
         boost::this_fiber::sleep_until(t0 + ms);
         time_point t1 = Clock::now();
         std::chrono::nanoseconds ns = (t1 - t0) - ms;
-        std::chrono::nanoseconds err = ms / 100;
-        // The time slept is within 1% of 500ms
+        std::chrono::nanoseconds err = ms / 10;
         // This test is spurious as it depends on the time the thread system switches the threads
         BOOST_CHECK((std::max)(ns.count(), -ns.count()) < (err+std::chrono::milliseconds(1000)).count());
-        //BOOST_TEST(std::abs(static_cast<long>(ns.count())) < (err+std::chrono::milliseconds(1000)).count());
     }
 }