mirror of https://github.com/CGAL/cgal
more efficient usage of mutex. The lock is only done
if the build need to be done. We have an extra "if (m_need_build)" but otherwise we would need to use mutex::try_lock() which results in more code and as efficient.
This commit is contained in:
parent
a09f6640f5
commit
f8449dcec4
|
|
@ -28,6 +28,7 @@
|
|||
#include <boost/optional.hpp>
|
||||
|
||||
#ifdef CGAL_HAS_THREADS
|
||||
#warning USING THEADS
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#endif
|
||||
|
||||
|
|
@ -221,12 +222,14 @@ namespace CGAL {
|
|||
#endif
|
||||
|
||||
const Node* root_node() const {
|
||||
if(m_need_build){
|
||||
#ifdef CGAL_HAS_THREADS
|
||||
//this ensure that build() will be called once
|
||||
boost::mutex::scoped_lock scoped_lock(internal_tree_mutex);
|
||||
#endif
|
||||
if(m_need_build)
|
||||
#endif
|
||||
const_cast< AABB_tree<AABBTraits>* >(this)->build();
|
||||
}
|
||||
return m_p_root_node;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue