Rosetta 3.5
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
protocols
boinc
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
16
#include <
protocols/boinc/BoincPoseObserver.hh
>
17
18
#include <
protocols/boinc/boinc.hh
>
19
20
#include <
core/pose/Pose.hh
>
21
#include <
core/pose/signals/ConformationEvent.hh
>
22
23
#include <
core/io/serialization/serialize_pose.hh
>
24
25
26
namespace
protocols {
27
namespace
boinc {
28
29
/// @brief default constructor
30
BoincCurrentPoseObserver::BoincCurrentPoseObserver
()
31
{
32
shmem_
= protocols::boinc::Boinc::get_shmem();
33
}
34
35
36
/// @brief default destructor
37
BoincCurrentPoseObserver::~BoincCurrentPoseObserver
()
38
{
39
detach_from
();
40
}
41
42
43
/// @brief attach to Pose
44
void
45
BoincCurrentPoseObserver::attach_to
(
Pose
& pose )
46
{
47
detach_from
();
48
conf_event_link_
= pose.
attach_conformation_obs
( &
BoincCurrentPoseObserver::on_conf_change
,
this
);
49
}
50
51
52
/// @brief detach from Pose
53
void
54
BoincCurrentPoseObserver::detach_from
()
55
{
56
conf_event_link_
.invalidate();
57
}
58
59
60
/// @brief on receiving an ConformationEvent, copy Pose to boinc shared memory
61
void
62
BoincCurrentPoseObserver::on_conf_change
(
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) {
76
core::io::serialization::BUFFER
b
((
char
*)(&
shmem_
->
current_pose_buf
),
POSE_BUFSIZE
);
77
write_binary
(*event.pose,
b
);
78
shmem_
->
current_pose_exists
= 1;
79
}
80
boinc_end_critical_section();
81
Boinc::unlock_semaphore
();
82
}
83
}
84
85
86
}
// namespace boinc
87
}
// namespace protocols
88
89
#endif
Generated on Sat Jun 1 2013 11:43:28 for Rosetta 3.5 by
1.8.4