void consumer2(the_ostream &mos, boost::sync_queue<int> & sbq) { using namespace boost; try { for(int i=0; ;++i) { int r; queue_op_status st = sbq.try_pull(r); if (queue_op_status::closed == st) break; if (queue_op_status::success == st) { mos << i << " pull(" << r << ")\n"; } this_thread::sleep_for(chrono::milliseconds(250)); } } catch(...) { mos << "exception !!!\n"; } }