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>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
#ifdef CGAL_HAS_THREADS
|
#ifdef CGAL_HAS_THREADS
|
||||||
|
#warning USING THEADS
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -221,12 +222,14 @@ namespace CGAL {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const Node* root_node() const {
|
const Node* root_node() const {
|
||||||
#ifdef CGAL_HAS_THREADS
|
if(m_need_build){
|
||||||
//this ensure that build() will be called once
|
#ifdef CGAL_HAS_THREADS
|
||||||
boost::mutex::scoped_lock scoped_lock(internal_tree_mutex);
|
//this ensure that build() will be called once
|
||||||
#endif
|
boost::mutex::scoped_lock scoped_lock(internal_tree_mutex);
|
||||||
if(m_need_build)
|
if(m_need_build)
|
||||||
const_cast< AABB_tree<AABBTraits>* >(this)->build();
|
#endif
|
||||||
|
const_cast< AABB_tree<AABBTraits>* >(this)->build();
|
||||||
|
}
|
||||||
return m_p_root_node;
|
return m_p_root_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue