opensurgsim
Barrier.h
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 
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
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
bool wait(bool success)
Waits until all count threads have called wait.
Definition: Barrier.cpp:35
Barrier(size_t count)
Construct the barrier.
Definition: Barrier.cpp:26
Barrier class, synchronize a set of threads to wait at a common point, all threads will wait at Barri...
Definition: Barrier.h:45
The header that provides the assertion API.