void send_messages( connection_list connections ) { // We try to handle all sends connection_list::iterator end = std::remove_if( connections.begin() , connections.end() , [](connection_ptr sender) -> bool { if(sender->send()) { error_code ec; sender->postprocess_handler_(ec, sender->destination(), sender); return true; } return false; } ); // If some are still in progress, give them back if(connections.begin() != end) { std::unique_lock<mutex_type> l(connections_mtx_); connections_.insert( connections_.end() , std::make_move_iterator(connections.begin()) , std::make_move_iterator(end) ); } }
void receive_messages( connection_list connections ) { // We try to handle all receives connection_list::iterator end = std::remove_if( connections.begin() , connections.end() , [](connection_ptr & rcv) -> bool { return rcv->receive(); } ); // If some are still in progress, give them back if(connections.begin() != end) { boost::unique_lock<mutex_type> l(connections_mtx_); connections_.insert( connections_.end() , std::make_move_iterator(connections.begin()) , std::make_move_iterator(end) ); } }