本文整理汇总了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;
}
示例2: notify_all_fn
void notify_all_fn( boost::fibers::condition_variable_any & cond) {
cond.notify_all();
}