Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WorkUnit.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/WorkUnit.cc
11 /// @brief
12 /// @author Ken Jung
13 
15 #include <basic/Tracer.hh>
16 
17 #if defined(WIN32) || defined(__CYGWIN__)
18  #include <ctime>
19  #ifndef WIN_PYROSETTA
20  #include <windows.h>
21  #endif
22 #endif
23 
24 namespace protocols {
25 namespace wum2 {
26 
27 
28 static basic::Tracer TR("protocols.wum2.WorkUnit");
29 
30 #ifdef USELUA
31 void lregister_WorkUnit( lua_State * lstate ) {
32  luabind::module(lstate, "protocols")
33  [
34  luabind::namespace_("wum2")
35  [
36  luabind::class_<WorkUnit>("WorkUnit")
37  ]
38  ];
39 }
40 void lregister_WorkUnit_Wait( lua_State * lstate ) {
41  luabind::module(lstate, "protocols")
42  [
43  luabind::namespace_("wum2")
44  [
45  luabind::class_<WorkUnit_Wait>("WorkUnit_Wait")
46  ]
47  ];
48 }
49 void lregister_WorkUnit_ElScripts( lua_State * lstate ) {
50  luabind::module(lstate, "protocols")
51  [
52  luabind::namespace_("wum2")
53  [
54  luabind::class_<WorkUnit_ElScripts>("WorkUnit_ElScripts")
55  ]
56  ];
57 }
58 #endif
59 
60 // ---------- WorkUnit --------------
62 ( core::Size master,
63  core::Size trajectory_idx ) :
64 
65  master_(master),
66  trajectory_idx_(trajectory_idx)
67 {
68  unixtime_creation_ = time(NULL);
69  unixtime_start_ = 0;
70  unixtime_stop_ = 0;
71  create_unique_id();
72  prioritize_ = false;
73 }
74 
75 void
76 WorkUnit::print( std::ostream & out, bool /*verbose*/ ) const {
77  out << "WU_id: " << id_ << std::endl;
78  out << "WU_time_create:" << unixtime_creation_<< std::endl;
79  out << "WU_time_start: " << unixtime_start_<< std::endl;
80  out << "WU_time_stop: " << unixtime_stop_<< std::endl;
81 }
82 
83 
85  unixtime_start_ = time(NULL);
86 }
87 
89  unixtime_stop_ = time(NULL);
90 }
91 
94 }
95 
97  id_ = 0;
98 }
99 
100 // ---------- WorkUnit_Wait --------------
101 
103 ( core::Size master,
104  core::Size trajectory_idx,
105  long wait_time ) :
106  WorkUnit( master, trajectory_idx ),
107  wait_time_(wait_time)
108 {}
109 
111  //TR << "Waiting for " << header.extra_data_1_ << std::endl;
112 #ifdef _WIN32
113  #ifndef WIN_PYROSETTA
114  Sleep( wait_time_ * 1000 );
115  #endif
116 #else
117  sleep( wait_time_ );
118 #endif
119 }
120 
121 
122 // ---------- WorkUnit_ElScripts --------------
123 
125  core::Size master,
126  core::Size trajectory_idx,
129  std::string name
130  ) :
131  WorkUnit( master, trajectory_idx ),
132  name_(name),
133  pipemap_(p),
134  state_(state)
135 {}
136 
138 }
139 
140 
141 
142 } //wum2
143 } //protocols
144