Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Slave.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/elscripts/Slave.hh
11 /// @brief the non_mpi slave role of elscripts
12 /// used by single node, shares fxns with MPI_Slave
13 /// @author Ken Jung
14 
15 #ifndef INCLUDED_protocols_elscripts_Slave_hh
16 #define INCLUDED_protocols_elscripts_Slave_hh
17 
18 #ifdef USELUA
22 
23 namespace protocols {
24 namespace elscripts {
25 
26 void lregister_Slave( lua_State * lstate );
27 
28 class Slave : public BaseRole {
29  public:
30  // default memory limit is 2GB
31  // default reserved mem size is 100MB as recommended by fpd
32  Slave( int master = 1, boost::uint64_t mem_limit=2147483648, boost::uint64_t reserved_mem=104857600, boost::uint64_t reserved_mem_multiplier=10 );
33  ~Slave(){}
34  void go();
35 
36  boost::uint64_t available_mem() {
37  boost::uint64_t buff_mem =
38  master_comm_->current_mem() +
39  reserved_mem_ * reserved_mem_multiplier_ +
40  mover_cache_mem();
41  if( buff_mem >= mem_limit_ ) {
42  return 0;
43  } else {
44  return mem_limit_ - buff_mem;
45  }
46  }
47 
48  // this is me being sloppy and lazy
49  protocols::wum2::WUQueue & inq() { return master_comm_->inq(); }
50  protocols::wum2::WUQueue & outq() { return master_comm_->outq(); }
51 
52  protected:
53  boost::uint64_t current_mem() {
54  return master_comm_->current_mem() + mover_cache_mem();
55  }
56 
57  protected:
58  protocols::wum2::EndPointSP master_comm_;
59 
60  int master_;
61 };
62 
63 } //elscripts
64 } //protocols
65 #endif
66 #endif