
//
// Automatically generated by Flow Graph Analyzer: C++ Code Generator Plugin version 2020 1.1.17946
//

#define TBB_DEPRECATED_LIMITER_NODE_CONSTRUCTOR 1
#define TBB_PREVIEW_FLOW_GRAPH_NODES 1
#include "tbb/flow_graph.h"
#include "tbb/tick_count.h"
#include "tbb/atomic.h"
#include <cstdlib>

using namespace std;
using namespace tbb;
using namespace tbb::flow;

size_t key_from_message(char *k) {
    return reinterpret_cast<size_t>(k);
}

template<typename T>
size_t key_from_message(const T &k) {
	return static_cast<size_t>(k);
}

static void spin_for( double weight = 0.0 ) {
	if ( weight > 0.0 ) {
		tick_count t1, t0 = tick_count::now();
		const double weight_multiple = 1e-6;
		const double end_time = weight_multiple * weight;
		do {
			t1 = tick_count::now();
		} while ( (t1-t0).seconds() < end_time );
	}
}



int build_and_run_h0_g0() {
	graph h0_g0;
	size_t source_node_2_trip_counter = 0;
	source_node< int > source_node_2( h0_g0,
		// REPLACE THE FOLLOWING WITH YOUR OWN CODE
		// the dummy body below sends a single default constructed output
		// when replaced, you can also remove the source_node_2_trip_counter variable declaration above
		[&source_node_2_trip_counter]( int &v ) -> bool {
			if (source_node_2_trip_counter < 1) {
				spin_for(1.000000);
				v = int();
				++source_node_2_trip_counter;
				return true;
			}
			return false;
		}
	, false);
	// split_node< tbb::flow::tuple<int, int>, cache_aligned_allocator< tbb::flow::tuple<int, int> > > split_node_4( h0_g0 );
    tbb::flow::split_node< tbb::flow::tuple<int, int> > split_node_4(h0_g0);

	#if TBB_PREVIEW_FLOW_GRAPH_TRACE
	h0_g0.set_name("h0_g0");
	source_node_2.set_name("source_node_2");
	split_node_4.set_name("split_node_4");
	#endif

	make_edge( source_node_2, split_node_4 );
	source_node_2.activate();
	h0_g0.wait_for_all();
	return 0;
}

int main(int argc, char *argv[]) {
	return build_and_run_h0_g0();
}
