Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WUQueueBuffer.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/wum2/WUQueueBuffer.cc
11 /// @brief Foward decls for WUQueueBuffer, memory aware structure that links irecv and isend
12 /// with their mpi::request status, so buffers are maintained until messages are sent/recvd
13 /// @author Ken Jung
14 
15 #ifdef USEBOOSTMPI
16 
18 
19 namespace protocols {
20 namespace wum2 {
21 
22 // mpi-aware, links buffer for an irecv/isend with the mpi::request status
23 
24 
25 WUQueueBuffer::riterator
26 WUQueueBuffer::allocate_buffer(boost::uint64_t size) {
27  boost::mpi::request req;
28  boost::shared_ptr< std::vector < WorkUnitSP > > vec( new std::vector< WorkUnitSP > ) ;
29  buffer_.push_back( boost::make_tuple(size,req, vec) );
30  current_mem_ += size;
31  return buffer_.rbegin();
32 }
33 
34 std::vector< WorkUnitSP >
35 WUQueueBuffer::cleanup_reqs() {
36  std::vector< WorkUnitSP > vec;
37  iterator itr = buffer_.begin();
38  while( itr != buffer_.end() ) {
39  if( itr->get<1>().test().is_initialized() ){
40  current_mem_ -= itr->get<0>();
41  vec.insert( vec.end(), itr->get<2>()->begin(), itr->get<2>()->end() );
42  itr = buffer_.erase(itr);
43  } else {
44  itr++;
45  }
46  }
47  return vec;
48 }
49 
50 } // wum2
51 } // protocols
52 #endif