当前位置: 首页>>代码示例>>C++>>正文


C++ condition_variable_any::notify_all方法代码示例

本文整理汇总了C++中boost::fibers::condition_variable_any::notify_all方法的典型用法代码示例。如果您正苦于以下问题:C++ condition_variable_any::notify_all方法的具体用法?C++ condition_variable_any::notify_all怎么用?C++ condition_variable_any::notify_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::fibers::condition_variable_any的用法示例。


在下文中一共展示了condition_variable_any::notify_all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main() {
    try {
        boost::fibers::use_scheduling_algorithm< boost::fibers::algo::shared_work >();
        unsigned int n = std::thread::hardware_concurrency();
        barrier b( n);
        bind_to_processor( n - 1);
        std::size_t size{ 1000000 };
        std::size_t div{ 10 };
        std::vector< std::thread > threads;
        for ( unsigned int i = 1; i < n; ++i) {
            threads.push_back( std::thread( thread, i - 1, & b) );
        };
        allocator_type salloc{ allocator_type::traits_type::page_size() };
        std::uint64_t result{ 0 };
        duration_type duration{ duration_type::zero() };
        channel_type rc{ 2 };
        b.wait();
        time_point_type start{ clock_type::now() };
        skynet( salloc, rc, 0, size, div);
        result = rc.value_pop();
        duration = clock_type::now() - start;
        std::cout << "Result: " << result << " in " << duration.count() / 1000000 << " ms" << std::endl;
        lock_type lk( mtx);
        done = true;
        lk.unlock();
        cnd.notify_all();
        for ( std::thread & t : threads) {
            t.join();
        }
        std::cout << "done." << std::endl;
        return EXIT_SUCCESS;
    } catch ( std::exception const& e) {
        std::cerr << "exception: " << e.what() << std::endl;
    } catch (...) {
        std::cerr << "unhandled exception" << std::endl;
    }
	return EXIT_FAILURE;
}
开发者ID:alexeykuzmin0,项目名称:ThePlatform,代码行数:38,代码来源:skynet_shared_join.cpp

示例2: notify_all_fn

void notify_all_fn( boost::fibers::condition_variable_any & cond) {
	cond.notify_all();
}
开发者ID:alexeykuzmin0,项目名称:ThePlatform,代码行数:3,代码来源:test_condition_variable_any_dispatch.cpp


注:本文中的boost::fibers::condition_variable_any::notify_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。