SurgSim
Framework
Barrier.h
Go to the documentation of this file.
1
// This file is a part of the OpenSurgSim project.
2
// Copyright 2013, SimQuest Solutions Inc.
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License");
5
// you may not use this file except in compliance with the License.
6
// You may obtain a copy of the License at
7
//
8
// http://www.apache.org/licenses/LICENSE-2.0
9
//
10
// Unless required by applicable law or agreed to in writing, software
11
// distributed under the License is distributed on an "AS IS" BASIS,
12
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
// See the License for the specific language governing permissions and
14
// limitations under the License.
15
16
// Based on barrier.hpp from Boost 1.51
17
// Copyright (C) 2002-2003
18
// David Moore, William E. Kempf
19
// Copyright (C) 2007-8 Anthony Williams
20
//
21
// Which was distributed under the Boost Software License, Version 1.0.
22
// (See accomanying NOTICES or a copy at http://www.boost.org/LICENSE_1_0.txt)
23
24
#ifndef SURGSIM_FRAMEWORK_BARRIER_H
25
#define SURGSIM_FRAMEWORK_BARRIER_H
26
27
#include <boost/thread/mutex.hpp>
28
#include <boost/thread/condition_variable.hpp>
29
#include <string>
30
#include <stdexcept>
31
32
#include "
SurgSim/Framework/Assert.h
"
33
34
namespace
SurgSim
35
{
36
namespace
Framework
37
{
38
45
class
Barrier
46
{
47
public
:
50
explicit
Barrier
(
size_t
count);
51
61
bool
wait
(
bool
success);
62
63
private
:
64
boost::mutex
m_mutex
;
65
boost::condition_variable
m_cond
;
66
size_t
m_threshold
;
67
size_t
m_count
;
68
size_t
m_generation
;
69
bool
m_success
;
70
bool
m_successResult
;
71
};
72
73
}
// namespace Framework
74
}
// namespace SurgSim
75
76
#endif
SurgSim::Framework::Barrier::m_success
bool m_success
Definition:
Barrier.h:69
SurgSim::Framework::Barrier::m_successResult
bool m_successResult
Definition:
Barrier.h:70
SurgSim::Framework::Barrier::m_threshold
size_t m_threshold
Definition:
Barrier.h:66
SurgSim::Framework::Barrier::m_count
size_t m_count
Definition:
Barrier.h:67
SurgSim::Framework::Barrier
Barrier class, synchronize a set of threads to wait at a common point, all threads will wait at Barri...
Definition:
Barrier.h:45
SurgSim::Framework::Barrier::Barrier
Barrier(size_t count)
Construct the barrier.
Definition:
Barrier.cpp:26
Assert.h
SurgSim
Definition:
CompoundShapeToGraphics.cpp:29
SurgSim::Framework::Barrier::m_generation
size_t m_generation
Definition:
Barrier.h:68
SurgSim::Framework::Barrier::m_cond
boost::condition_variable m_cond
Definition:
Barrier.h:65
SurgSim::Framework::Barrier::wait
bool wait(bool success)
Waits until all count threads have called wait.
Definition:
Barrier.cpp:35
SurgSim::Framework::Barrier::m_mutex
boost::mutex m_mutex
Definition:
Barrier.h:64
Generated on Sun Feb 9 2020 17:22:37 for OpenSurgSim by
1.8.16