Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SingleNode.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/elscripts/SingleNode.cc
11 /// @brief the slave role of elscripts
12 /// @author Ken Jung
13 
14 #ifdef USELUA
15 // this is useless without lua
17 
20 
21 #include <basic/Tracer.hh>
22 
23 namespace protocols {
24 namespace elscripts {
25 
26 void lregister_SingleNode( lua_State * lstate ) {
27  lregister_Slave( lstate );
28  lregister_Master( lstate );
29  luabind::module(lstate, "protocols")
30  [
31  luabind::namespace_("elscripts")
32  [
33  luabind::class_<SingleNode>("SingleNode")
34  ]
35  ];
36 }
37 
38 static basic::Tracer TR("protocols.elscripts.SingleNode");
39 
40 SingleNode::SingleNode( boost::uint64_t mem_limit, boost::uint64_t reserved_mem, boost::uint64_t reserved_mem_multiplier) {
41  // here they share the same memory limit, which is wrong
42  // they should be passed functors to SingleNode's total memory, including both roles
43  // or just give them half the total mem each
44  master_ = MasterSP( new Master( 1, mem_limit, reserved_mem, reserved_mem_multiplier ) );
45  slave_ = SlaveSP( new Slave( 1, mem_limit, reserved_mem, reserved_mem_multiplier ) );
46 }
47 
48 void SingleNode::go(){
49  while( 1 ) {
50  master_->go();
51  slave_->inq().push_back(master_->outq().pop_all());
52  slave_->go();
53  master_->inq().push_back(slave_->outq().pop_all());
54  }
55 }
56 
57 
58 } //elscripts
59 } //protocols
60 #endif