int main(int argc, char * argv[]) { int tasks = 10; // dummy, should be taken from the input line // allocator must be initialized before using it allocator.init(); // declare a pipeline object ff_pipeline pipe_a; // add stages in order: // the first stage added is the first pipeline stage // the i-th stage added is the i-th pipeline stage pipe_a.add_stage(new GenerateStream(tasks)); // we create a farm to process increments in the second stage // declare a ff_farm object ff_farm<> farm; // default collector farm.add_collector(NULL); // declare worker vector (string) std::vector workers; // two workers workers.push_back(new IntIncStage); workers.push_back(new IntIncStage); // add workers to farm farm.add_workers(workers); // second pipeline stage is the farm pipe_a.add_stage(&farm); // the third one is the print stream pipe_a.add_stage(new DrainStage); // now we ca run the application: std::cout << "Starting application ..." << std::endl; pipe_a.run(); std::cout << "Application started" << std::endl; // here more (unrelated) work can be performed ... // when results are needed we should wait for application termination pipe_a.wait(); // alternatively, if we have nothing else to do, we can issue a single // call such as: pipe_a.run_and_wait_end(); // in this case the pipeline is started and its termination awaited // synchronously std::cout << "Application terminated" << std::endl; return(0); }