Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BoincPoseObserver.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/boinc/BoincPoseObserver.cc
11 /// @brief BoincPoseObserver class
12 
13 #ifdef BOINC_GRAPHICS
14 
15 // Unit headers
17 
18 #include <protocols/boinc/boinc.hh>
19 
20 #include <core/pose/Pose.hh>
22 
24 
25 
26 namespace protocols {
27 namespace boinc {
28 
29 /// @brief default constructor
31 {
32  shmem_ = protocols::boinc::Boinc::get_shmem();
33 }
34 
35 
36 /// @brief default destructor
38 {
39  detach_from();
40 }
41 
42 
43 /// @brief attach to Pose
44 void
46 {
47  detach_from();
49 }
50 
51 
52 /// @brief detach from Pose
53 void
55 {
56  conf_event_link_.invalidate();
57 }
58 
59 
60 /// @brief on receiving an ConformationEvent, copy Pose to boinc shared memory
61 void
63  ConformationEvent const & event
64 )
65 {
66  static int count = 0;
67  if (count > 0) {
68  count--;
69  return;
70  }
71  count = SKIP_FOR_EFFICIENCY;
72  if (!shmem_) return;
73  if (!Boinc::trywait_semaphore()) {
74  boinc_begin_critical_section();
75  if (event.pose->total_residue() > 0) {
77  write_binary(*event.pose,b);
79  }
80  boinc_end_critical_section();
82  }
83 }
84 
85 
86 } // namespace boinc
87 } // namespace protocols
88 
89 #endif