Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WUQueue.hh
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/WUQueue.hh
11 /// @brief deque of WU with memory tracking
12 /// @author Ken Jung
13 
14 #ifndef INCLUDED_protocols_wum2_WUQueue_hh
15 #define INCLUDED_protocols_wum2_WUQueue_hh
16 
19 #include <boost/cstdint.hpp>
20 #include <deque>
21 #include <vector>
22 
23 namespace protocols {
24 namespace wum2 {
25 
26 class WUQueue {
27  typedef std::pair< boost::uint64_t, WorkUnitSP > wu_mem_pair;
28  typedef std::deque< wu_mem_pair >::iterator iterator;
29 
30  public:
33 
34  boost::uint64_t current_mem() { return current_mem_; }
35 
36  boost::uint64_t size_front() { return empty() ? 0 : deque_.front().first; }
37 
38  void push_front( WorkUnitSP wu );
39  void push_back( WorkUnitSP wu );
40  void push_back( std::vector<WorkUnitSP> wulist );
42  std::vector<WorkUnitSP> pop_all();
43  bool empty() { return deque_.empty(); }
44  void clear() { deque_.clear(); }
45  int size() { return deque_.size(); }
46 
47  private:
48  boost::uint64_t serialized_size( WorkUnitSP wu );
49 
50  boost::uint64_t current_mem_;
51  std::deque< wu_mem_pair > deque_;
52 };
53 
54 }
55 }
56 
57 #endif
58