]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/fiber/performance/fiber/skynet_stealing_detach.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / fiber / performance / fiber / skynet_stealing_detach.cpp
index a0783a1eaf4aa84512dc7e87ce108b8fc5e9dd4f..fbc1b205271d63cf83be4775e1100c52500973d6 100644 (file)
@@ -60,10 +60,9 @@ void skynet( allocator_type & salloc, channel_type & c, std::size_t num, std::si
     }
 }
 
-void thread( std::uint32_t thread_count, barrier * b) {
+void thread( std::uint32_t thread_count) {
     // thread registers itself at work-stealing scheduler
     boost::fibers::use_scheduling_algorithm< boost::fibers::algo::work_stealing >( thread_count);
-    b->wait();
     lock_type lk( mtx);
     cnd.wait( lk, [](){ return done; });
     BOOST_ASSERT( done);
@@ -73,27 +72,18 @@ int main() {
     try {
         // count of logical cpus
         std::uint32_t thread_count = std::thread::hardware_concurrency();
-        // main-thread registers itself at work-stealing scheduler
-        boost::fibers::use_scheduling_algorithm< boost::fibers::algo::work_stealing >( thread_count);
-        barrier b{ thread_count };
         std::size_t size{ 1000000 };
         std::size_t div{ 10 };
-        // Windows 10 and FreeBSD require a fiber stack of 8kb
-        // otherwise the stack gets exhausted
-        // stack requirements must be checked for other OS too
-#if BOOST_OS_WINDOWS || BOOST_OS_BSD
         allocator_type salloc{ 2*allocator_type::traits_type::page_size() };
-#else
-        allocator_type salloc{ allocator_type::traits_type::page_size() };
-#endif
         std::uint64_t result{ 0 };
         channel_type rc{ 2 };
         std::vector< std::thread > threads;
         for ( std::uint32_t i = 1 /* count main-thread */; i < thread_count; ++i) {
             // spawn thread
-            threads.emplace_back( thread, thread_count, & b);
+            threads.emplace_back( thread, thread_count);
         }
-        b.wait();
+        // main-thread registers itself at work-stealing scheduler
+        boost::fibers::use_scheduling_algorithm< boost::fibers::algo::work_stealing >( thread_count);
         time_point_type start{ clock_type::now() };
         skynet( salloc, rc, 0, size, div);
         result = rc.value_pop();