// // join_many.cpp // // Copyright (c) 2007 - 2009 Yigong Liu (yigongliu at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include #include #include using namespace std; using namespace boost; using namespace boost::join; logger log1("log"); // join multiple input streams into one output stream template class join_many : public joint { public: vector > inputs; synch, void> output; join_many(int num) : inputs(num) { chord(output, inputs, &join_many::chord_body); } vector chord_body(void_t out, vector in) { return in; } }; void thread_sleep(int sec) { boost::xtime xt; boost::xtime_get(&xt, boost::TIME_UTC); xt.sec += sec; boost::thread::sleep(xt); } enum { num_chan = 4, num_test = 5 }; void collect(synch,void> output) { vector results; for(int i=0; i input) { int start = p*num_test; int end = start+num_test; for(int i=start; i merger(num_chan); //spawn distributor tasks for(int i=0; i