void test_single_dest() { // push only tbb::flow::graph g; tbb::flow::source_node<T> src(g, source_body<T>() ); test_push_receiver<T> dest; tbb::flow::make_edge( src, dest ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { ASSERT( dest.get_count(i) == 1, NULL ); } // push only tbb::atomic<int> counters3[N]; tbb::flow::source_node<T> src3(g, source_body<T>() ); function_body<T> b3( counters3 ); tbb::flow::function_node<T,bool> dest3(g, tbb::flow::unlimited, b3 ); tbb::flow::make_edge( src3, dest3 ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { int v = counters3[i]; ASSERT( v == 1, NULL ); } // push & pull tbb::flow::source_node<T> src2(g, source_body<T>() ); tbb::atomic<int> counters2[N]; function_body<T> b2( counters2 ); tbb::flow::function_node<T,bool> dest2(g, tbb::flow::serial, b2 ); tbb::flow::make_edge( src2, dest2 ); #if TBB_PREVIEW_FLOW_GRAPH_FEATURES ASSERT(src2.successor_count() == 1, NULL); typename tbb::flow::source_node<T>::successor_vector_type my_succs; src2.copy_successors(my_succs); ASSERT(my_succs.size() == 1, NULL); #endif g.wait_for_all(); for (int i = 0; i < N; ++i ) { int v = counters2[i]; ASSERT( v == 1, NULL ); } // test copy constructor tbb::flow::source_node<T> src_copy(src); test_push_receiver<T> dest_c; ASSERT( src_copy.register_successor(dest_c), NULL ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { ASSERT( dest_c.get_count(i) == 1, NULL ); } }
void test_single_dest() { // push only tbb::flow::graph g; tbb::flow::source_node<T> src(g, source_body<T>() ); test_push_receiver<T> dest; tbb::flow::make_edge( src, dest ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { ASSERT( dest.get_count(i) == 1, NULL ); } // push only tbb::atomic<int> counters3[N]; tbb::flow::source_node<T> src3(g, source_body<T>() ); function_body<T> b3( counters3 ); tbb::flow::function_node<T,bool> dest3(g, tbb::flow::unlimited, b3 ); tbb::flow::make_edge( src3, dest3 ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { int v = counters3[i]; ASSERT( v == 1, NULL ); } // push & pull tbb::flow::source_node<T> src2(g, source_body<T>() ); tbb::atomic<int> counters2[N]; function_body<T> b2( counters2 ); tbb::flow::function_node<T,bool> dest2(g, tbb::flow::serial, b2 ); tbb::flow::make_edge( src2, dest2 ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { int v = counters2[i]; ASSERT( v == 1, NULL ); } // test copy constructor tbb::flow::source_node<T> src_copy(src); test_push_receiver<T> dest_c; ASSERT( src_copy.register_successor(dest_c), NULL ); g.wait_for_all(); for (int i = 0; i < N; ++i ) { ASSERT( dest_c.get_count(i) == 1, NULL ); } }