Changes in the "lock data structure" concept and models

The concept is now much more generic (SurjectiveLockDataStructure).
The names have been changed accordingly.
This commit is contained in:
Clement Jamin 2013-10-16 12:17:56 +02:00
parent 0d0d54277d
commit 6b65ad71da
13 changed files with 167 additions and 150 deletions

View File

@ -4,9 +4,14 @@ namespace CGAL {
/*! /*!
\ingroup PkgStlExtension \ingroup PkgStlExtension
The class `Spatial_grid_lock_data_structure_3` allows to lock The class `Spatial_lock_grid_3` allows to lock
points with coordinates (x, y, z) in a 3D grid. For example, points with coordinates (x, y, z) in a 3D grid. For example,
it can be used by concurrent algorithms to lock simplices. it can be used by concurrent algorithms to lock simplices.
It is a model of `SurjectiveLockDataStructure`, with `Object` being
`P3` and `S(point)` being the cell of the 3D grid containing `point`.
`P3` must provide x(), y() and z() functions,
returning the respective point coordinates as numbers whose type is a
model of the concept of `CGAL::RealEmbeddable`.
\tparam Grid_lock_tag allows to choose the locking strategy used by the \tparam Grid_lock_tag allows to choose the locking strategy used by the
structure. The following tags are available: structure. The following tags are available:
@ -18,20 +23,20 @@ block (spin) if the thread owning the lock has a lower \"ID\" (each thread is
given an arbitrary ID) or return immediately otherwise. It uses atomics to given an arbitrary ID) or return immediately otherwise. It uses atomics to
perform lock operations. perform lock operations.
\cgalModels `SpatialLockDataStructure_3` \cgalModels `SurjectiveLockDataStructure`
*/ */
template <typename Grid_lock_tag> template <typename Grid_lock_tag>
class Spatial_grid_lock_data_structure_3 class Spatial_lock_grid_3
{ {
public: public:
/// \name Creation /// \name Creation
/// @{ /// @{
/// Construct the lock grid of size `bbox`, with `num_grid_cells_per_axis` /// Constructs the lock grid of size `bbox`, with `num_grid_cells_per_axis`
/// cells per axis. /// cells per axis.
Spatial_grid_lock_data_structure_3(const Bbox_3 &bbox, Spatial_lock_grid_3(const Bbox_3 &bbox,
int num_grid_cells_per_axis); int num_grid_cells_per_axis);
/// @} /// @}
@ -39,10 +44,10 @@ public:
/// \name Operations /// \name Operations
/// @{ /// @{
/// Set the bounding box of the domain. /// Sets the bounding box of the domain.
void set_bbox(const CGAL::Bbox_3 &bbox); void set_bbox(const CGAL::Bbox_3 &bbox);
/// @} /// @}
}; /* end Spatial_grid_lock_data_structure_3 */ }; /* end Spatial_lock_grid_3 */
} /* end namespace CGAL */ } /* end namespace CGAL */

View File

@ -1,50 +0,0 @@
/*!
\ingroup PkgStlExtensionConcepts
\cgalConcept
The concept `SpatialLockDataStructure_3` is intended to be used by concurrent
algorithms. It allows to lock points with coordinates (x, y, z).
The template parameter type `P3` appearing in member functions
must provide x(), y() and z() functions,
returning the respective point coordinates as numbers whose type is a
model of the concept of `CGAL::RealEmbeddable`.
Note that it is allowed to \"lock too much\". E.g., the data structure
may be a voxel grid and locking a point may be locking the voxel containing this point.
The only requirement is that when a thread owns the lock of a point, no other
thread can lock a point with the exact same coordinates.
\cgalHasModel `CGAL::Spatial_grid_lock_data_structure_3`
*/
class SpatialLockDataStructure_3 {
public:
/// \name Operations
/// @{
/// Test if `point` is locked (by this thread or by any other thread).
template <typename P3>
bool is_locked(const P3 &point);
/// Test if `point` is locked by this thread.
template <typename P3>
bool is_locked_by_this_thread(const P3 &point);
/// Try to lock `point`. Returns `true` if the point is already locked by this thread or if the point could be locked.
template <typename P3>
bool try_lock(const P3 &point);
/// Try to lock `point`. Returns `true` if the point is already locked by this thread or if the point could be locked.
/// \tparam no_spin If true, force non-blocking operation (never blocks). If false, use the default behavior (same as previous function).
template <bool no_spin, typename P3>
bool try_lock(const P3 &point);
/// Unlock all the locations locked by this thread.
void unlock_all_points_locked_by_this_thread();
/// Unlock all the locations locked by this thread except `point`.
template <typename P3>
void unlock_all_tls_locked_locations_but_one_point(const P3 &point);
/// @}
};

View File

@ -0,0 +1,57 @@
/*!
\ingroup PkgStlExtensionConcepts
\cgalConcept
The concept `SurjectiveLockDataStructure` is intended to be used by concurrent
algorithms. It allows to lock objects in a multi-threaded environment.
Note that it is allowed to \"lock too much\". E.g., the data structure
might be a voxel grid and locking a point might be locking the
voxel containing this point.
Thus, a point may also be locked because
another point in the same voxel has been locked.
The only requirement is that when a thread owns the lock of an object, no other
thread can lock the same object.
We call `S` the surjective function such as `S(object)`
is the \"thing\" that is locked when one tries to lock `object`.
In the previous example, `S(point)` is the voxel containing `point`.
\cgalHasModel `CGAL::Spatial_lock_grid_3`
*/
class SurjectiveLockDataStructure {
public:
/// \name Operations
/// @{
/// Test if `object` is locked (by this thread or by any other thread).
template <typename Object>
bool is_locked(const Object &object);
/// Test if `object` is locked by this thread.
template <typename Object>
bool is_locked_by_this_thread(const Object &object);
/// Try to lock `object`. Returns `true` if the object is already locked by this thread or if the object could be locked.
template <typename Object>
bool try_lock(const Object &object);
/// Try to lock `object`. Returns `true` if the object is already locked
/// by this thread or if the object could be locked.
/// \tparam no_spin If `true`, force non-blocking operation (in any case, the
/// function will return immediately, i.e.\ it will not
/// wait for the ressource to be free).
/// If `false`, use the default behavior (same as previous function).
template <bool no_spin, typename Object>
bool try_lock(const Object &object);
/// Unlock everything that is locked by this thread.
void unlock_everything_locked_by_this_thread();
/// Unlock everything that is locked by this thread except `S(object)`.
template <typename Object>
void unlock_everything_locked_by_this_thread_but_one(const Object &object);
/// @}
};

View File

@ -17,8 +17,8 @@
// //
// Author(s) : Clement Jamin // Author(s) : Clement Jamin
#ifndef CGAL_MESH_3_LOCK_DATA_STRUCTURES_H #ifndef CGAL_STL_EXTENSION_SPATIAL_LOCK_GRID_3_H
#define CGAL_MESH_3_LOCK_DATA_STRUCTURES_H #define CGAL_STL_EXTENSION_SPATIAL_LOCK_GRID_3_H
#ifdef CGAL_LINKED_WITH_TBB #ifdef CGAL_LINKED_WITH_TBB
@ -46,12 +46,12 @@ struct Tag_non_blocking_with_mutexes {};
struct Tag_priority_blocking {}; struct Tag_priority_blocking {};
//***************************************************************************** //*****************************************************************************
// class Spatial_grid_lock_data_structure_base_3 // class Spatial_lock_grid_base_3
// (Uses Curiously recurring template pattern) // (Uses Curiously recurring template pattern)
//***************************************************************************** //*****************************************************************************
template <typename Derived> template <typename Derived>
class Spatial_grid_lock_data_structure_base_3 class Spatial_lock_grid_base_3
{ {
#ifdef CGAL_DEBUG_GLOBAL_LOCK_DS #ifdef CGAL_DEBUG_GLOBAL_LOCK_DS
@ -364,7 +364,7 @@ public:
protected: protected:
// Constructor // Constructor
Spatial_grid_lock_data_structure_base_3(const Bbox_3 &bbox, Spatial_lock_grid_base_3(const Bbox_3 &bbox,
int num_grid_cells_per_axis) int num_grid_cells_per_axis)
: m_num_grid_cells_per_axis(num_grid_cells_per_axis), : m_num_grid_cells_per_axis(num_grid_cells_per_axis),
m_tls_grids(boost::bind(init_TLS_grid, num_grid_cells_per_axis)) m_tls_grids(boost::bind(init_TLS_grid, num_grid_cells_per_axis))
@ -373,7 +373,7 @@ protected:
} }
/// Destructor /// Destructor
~Spatial_grid_lock_data_structure_base_3() ~Spatial_lock_grid_base_3()
{ {
for( TLS_grid::iterator it_grid = m_tls_grids.begin() ; for( TLS_grid::iterator it_grid = m_tls_grids.begin() ;
it_grid != m_tls_grids.end() ; it_grid != m_tls_grids.end() ;
@ -465,27 +465,26 @@ protected:
//***************************************************************************** //*****************************************************************************
// class Spatial_grid_lock_data_structure_3 // class Spatial_lock_grid_3
//***************************************************************************** //*****************************************************************************
template <typename Grid_lock_tag = Tag_priority_blocking> template <typename Grid_lock_tag = Tag_priority_blocking>
class Spatial_grid_lock_data_structure_3; class Spatial_lock_grid_3;
//***************************************************************************** //*****************************************************************************
// class Spatial_grid_lock_data_structure_3<Tag_non_blocking> // class Spatial_lock_grid_3<Tag_non_blocking>
//***************************************************************************** //*****************************************************************************
template <> template <>
class Spatial_grid_lock_data_structure_3<Tag_non_blocking> class Spatial_lock_grid_3<Tag_non_blocking>
: public Spatial_grid_lock_data_structure_base_3< : public Spatial_lock_grid_base_3<
Spatial_grid_lock_data_structure_3<Tag_non_blocking> > Spatial_lock_grid_3<Tag_non_blocking> >
{ {
typedef Spatial_grid_lock_data_structure_base_3< typedef Spatial_lock_grid_base_3<
Spatial_grid_lock_data_structure_3<Tag_non_blocking> > Base; Spatial_lock_grid_3<Tag_non_blocking> > Base;
public: public:
// Constructors // Constructors
Spatial_grid_lock_data_structure_3(const Bbox_3 &bbox, Spatial_lock_grid_3(const Bbox_3 &bbox, int num_grid_cells_per_axis)
int num_grid_cells_per_axis)
: Base(bbox, num_grid_cells_per_axis) : Base(bbox, num_grid_cells_per_axis)
{ {
int num_cells = int num_cells =
@ -497,7 +496,7 @@ public:
m_grid[i] = false; m_grid[i] = false;
} }
~Spatial_grid_lock_data_structure_3() ~Spatial_lock_grid_3()
{ {
} }
@ -531,22 +530,20 @@ protected:
//***************************************************************************** //*****************************************************************************
// class Spatial_grid_lock_data_structure_3<Tag_priority_blocking> // class Spatial_lock_grid_3<Tag_priority_blocking>
//***************************************************************************** //*****************************************************************************
template <> template <>
class Spatial_grid_lock_data_structure_3<Tag_priority_blocking> class Spatial_lock_grid_3<Tag_priority_blocking>
: public Spatial_grid_lock_data_structure_base_3< : public Spatial_lock_grid_base_3<Spatial_lock_grid_3<Tag_priority_blocking> >
Spatial_grid_lock_data_structure_3<Tag_priority_blocking> >
{ {
typedef Spatial_grid_lock_data_structure_base_3< typedef Spatial_lock_grid_base_3<
Spatial_grid_lock_data_structure_3<Tag_priority_blocking> > Base; Spatial_lock_grid_3<Tag_priority_blocking> > Base;
public: public:
// Constructors // Constructors
Spatial_grid_lock_data_structure_3(const Bbox_3 &bbox, Spatial_lock_grid_3(const Bbox_3 &bbox, int num_grid_cells_per_axis)
int num_grid_cells_per_axis)
: Base(bbox, num_grid_cells_per_axis), : Base(bbox, num_grid_cells_per_axis),
m_tls_thread_ids(init_TLS_thread_ids) m_tls_thread_ids(init_TLS_thread_ids)
{ {
@ -556,7 +553,7 @@ public:
} }
/// Destructor /// Destructor
~Spatial_grid_lock_data_structure_3() ~Spatial_lock_grid_3()
{ {
} }
@ -633,22 +630,21 @@ protected:
}; };
//***************************************************************************** //*****************************************************************************
// class Spatial_grid_lock_data_structure_3<Tag_non_blocking_with_mutexes> // class Spatial_lock_grid_3<Tag_non_blocking_with_mutexes>
// Note: undocumented, for testing only... // Note: undocumented, for testing only...
//***************************************************************************** //*****************************************************************************
template <> template <>
class Spatial_grid_lock_data_structure_3<Tag_non_blocking_with_mutexes> class Spatial_lock_grid_3<Tag_non_blocking_with_mutexes>
: public Spatial_grid_lock_data_structure_base_3< : public Spatial_lock_grid_base_3<
Spatial_grid_lock_data_structure_3<Tag_non_blocking_with_mutexes> > Spatial_lock_grid_3<Tag_non_blocking_with_mutexes> >
{ {
typedef Spatial_grid_lock_data_structure_base_3< typedef Spatial_lock_grid_base_3<
Spatial_grid_lock_data_structure_3<Tag_non_blocking_with_mutexes> > Base; Spatial_lock_grid_3<Tag_non_blocking_with_mutexes> > Base;
public: public:
// Constructors // Constructors
Spatial_grid_lock_data_structure_3(const Bbox_3 &bbox, Spatial_lock_grid_3(const Bbox_3 &bbox, int num_grid_cells_per_axis)
int num_grid_cells_per_axis)
: Base(bbox, num_grid_cells_per_axis) : Base(bbox, num_grid_cells_per_axis)
{ {
int num_cells = int num_cells =
@ -657,7 +653,7 @@ public:
} }
/// Destructor /// Destructor
~Spatial_grid_lock_data_structure_3() ~Spatial_lock_grid_3()
{ {
} }
@ -698,7 +694,7 @@ protected:
namespace CGAL { namespace CGAL {
template <typename Grid_lock_tag = void> template <typename Grid_lock_tag = void>
class Spatial_grid_lock_data_structure_3 class Spatial_lock_grid_3
{ {
}; };
@ -706,4 +702,4 @@ class Spatial_grid_lock_data_structure_3
#endif // CGAL_LINKED_WITH_TBB #endif // CGAL_LINKED_WITH_TBB
#endif // CGAL_MESH_3_LOCK_DATA_STRUCTURES_H #endif // CGAL_STL_EXTENSION_SPATIAL_LOCK_GRID_3_H

View File

@ -82,7 +82,7 @@ typedef Regular_triangulation_euclidean_traits_3<K> WK;
typedef K::Point_3 Point; typedef K::Point_3 Point;
#ifdef CONCURRENT_TRIANGULATION_3 #ifdef CONCURRENT_TRIANGULATION_3
typedef CGAL::Spatial_grid_lock_data_structure_3< typedef CGAL::Spatial_lock_grid_3<
CGAL::Tag_priority_blocking> Lock_ds; CGAL::Tag_priority_blocking> Lock_ds;
// Delaunay T3 // Delaunay T3

View File

@ -86,7 +86,7 @@ private:
* and point location is then O(n^(1/3)) time * and point location is then O(n^(1/3)) time
*/ */
#ifdef CONCURRENT_TRIANGULATION_3 #ifdef CONCURRENT_TRIANGULATION_3
typedef CGAL::Spatial_grid_lock_data_structure_3< typedef CGAL::Spatial_lock_grid_3<
CGAL::Tag_priority_blocking> Lock_ds; CGAL::Tag_priority_blocking> Lock_ds;
typedef CGAL::Triangulation_data_structure_3< typedef CGAL::Triangulation_data_structure_3<
Vertex_base<Kernel>, Vertex_base<Kernel>,

View File

@ -32,14 +32,16 @@ provided before \cgal 3.6 by `Triangulation_hierarchy_3`.
An example of use can be found in the user An example of use can be found in the user
manual \ref Triangulation3exfastlocation. manual \ref Triangulation3exfastlocation.
\tparam SpatialLockDataStructure_3 is an optional parameter to specify the type of the spatial lock data structure. \tparam SurjectiveLockDataStructure is an optional parameter to specify the type of the spatial lock data structure.
It is only used if the triangulation data structure used is concurrency-safe (i.e.\ when It is only used if the triangulation data structure used is concurrency-safe (i.e.\ when
TriangulationDataStructure_3::Concurrency_tag is Parallel_tag). TriangulationDataStructure_3::Concurrency_tag is Parallel_tag).
It must be a model of the `SpatialLockDataStructure_3` concept. It must be a model of the `SurjectiveLockDataStructure` concept,
The default value is `Spatial_grid_lock_data_structure_3<Tag_priority_blocking>` if with `Object` being a `Point`.
The default value is `Spatial_lock_grid_3<Tag_priority_blocking>` if
the triangulation data structure is concurrency-safe, and `void` otherwise. the triangulation data structure is concurrency-safe, and `void` otherwise.
In order to use concurrent operations, the user must provide a reference to a `SpatialLockDataStructure_3` In order to use concurrent operations, the user must provide a
instance via the constructor or `set_lock_data_structure`. reference to a `SurjectiveLockDataStructure`
instance via the constructor or `Triangulation_3::set_lock_data_structure`.
If `TriangulationDataStructure_3::Concurrency_tag` is `Parallel_tag`, some operations, If `TriangulationDataStructure_3::Concurrency_tag` is `Parallel_tag`, some operations,
such as insertion/removal of a range of points, are performed in parallel. See such as insertion/removal of a range of points, are performed in parallel. See
@ -48,13 +50,13 @@ the documentation of the operations for more details.
\sa `CGAL::Regular_triangulation_3` \sa `CGAL::Regular_triangulation_3`
*/ */
template< typename DelaunayTriangulationTraits_3, typename TriangulationDataStructure_3, typename LocationPolicy, typename SpatialLockDataStructure_3 > template< typename DelaunayTriangulationTraits_3, typename TriangulationDataStructure_3, typename LocationPolicy, typename SurjectiveLockDataStructure >
class Delaunay_triangulation_3 : class Delaunay_triangulation_3 :
public Triangulation_3<DelaunayTriangulationTraits_3, public Triangulation_3<DelaunayTriangulationTraits_3,
Delaunay_triangulation_3<DelaunayTriangulationTraits_3, Delaunay_triangulation_3<DelaunayTriangulationTraits_3,
TriangulationDataStructure_3, TriangulationDataStructure_3,
LocationPolicy>::Triangulation_data_structure, LocationPolicy>::Triangulation_data_structure,
SpatialLockDataStructure_3 SurjectiveLockDataStructure
> >
{ {
@ -72,7 +74,7 @@ typedef LocationPolicy Location_policy;
/*! /*!
*/ */
typedef SpatialLockDataStructure_3 Lock_data_structure; typedef SurjectiveLockDataStructure Lock_data_structure;
/// @} /// @}
@ -114,12 +116,12 @@ must be provided if concurrency is enabled.
*/ */
Delaunay_triangulation_3 Delaunay_triangulation_3
(const DelaunayTriangulationTraits_3& traits = DelaunayTriangulationTraits_3(), (const DelaunayTriangulationTraits_3& traits = DelaunayTriangulationTraits_3(),
SpatialLockDataStructure_3 *lock_ds = NULL); Lock_data_structure *lock_ds = NULL);
/*! /*!
Copy constructor. Copy constructor.
The pointer to the lock data structure is not copied. Thus, the copy won't be The pointer to the lock data structure is not copied. Thus, the copy won't be
concurrency-safe as long as the user has not called `set_lock_data_structure`. concurrency-safe as long as the user has not called `Triangulation_3::set_lock_data_structure`.
*/ */
Delaunay_triangulation_3 (const Delaunay_triangulation_3 & dt1); Delaunay_triangulation_3 (const Delaunay_triangulation_3 & dt1);
@ -130,14 +132,14 @@ traits class argument and calling `insert(first,last)`.
template < class InputIterator > template < class InputIterator >
Delaunay_triangulation_3 (InputIterator first, InputIterator last, Delaunay_triangulation_3 (InputIterator first, InputIterator last,
const DelaunayTriangulationTraits_3& traits = DelaunayTriangulationTraits_3(), const DelaunayTriangulationTraits_3& traits = DelaunayTriangulationTraits_3(),
SpatialLockDataStructure_3 *lock_ds = NULL); Lock_data_structure *lock_ds = NULL);
/*! /*!
Same as before, with last two parameters in reverse order. Same as before, with last two parameters in reverse order.
*/ */
template < class InputIterator > template < class InputIterator >
Delaunay_triangulation_3 (InputIterator first, InputIterator last, Delaunay_triangulation_3 (InputIterator first, InputIterator last,
SpatialLockDataStructure_3 *lock_ds, Lock_data_structure *lock_ds,
const DelaunayTriangulationTraits_3& traits = DelaunayTriangulationTraits_3()); const DelaunayTriangulationTraits_3& traits = DelaunayTriangulationTraits_3());
/// @} /// @}

View File

@ -32,14 +32,16 @@ of all simplices are regular.
\tparam TriangulationDataStructure_3 is the triangulation data structure. \tparam TriangulationDataStructure_3 is the triangulation data structure.
It has the default value `Triangulation_data_structure_3<Triangulation_vertex_base_3<RegularTriangulationTraits_3>, Regular_triangulation_cell_base_3<RegularTriangulationTraits_3> >`. It has the default value `Triangulation_data_structure_3<Triangulation_vertex_base_3<RegularTriangulationTraits_3>, Regular_triangulation_cell_base_3<RegularTriangulationTraits_3> >`.
\tparam SpatialLockDataStructure_3 is an optional parameter to specify the type of the spatial lock data structure. \tparam SurjectiveLockDataStructure is an optional parameter to specify the type of the spatial lock data structure.
It is only used if the triangulation data structure used is concurrency-safe (i.e.\ when It is only used if the triangulation data structure used is concurrency-safe (i.e.\ when
TriangulationDataStructure_3::Concurrency_tag is Parallel_tag). TriangulationDataStructure_3::Concurrency_tag is Parallel_tag).
It must be a model of the `SpatialLockDataStructure_3` concept. It must be a model of the `SurjectiveLockDataStructure` concept,
The default value is `Spatial_grid_lock_data_structure_3<Tag_priority_blocking>` if with `Object` being a `Point`.
The default value is `Spatial_lock_grid_3<Tag_priority_blocking>` if
the triangulation data structure is concurrency-safe, and `void` otherwise. the triangulation data structure is concurrency-safe, and `void` otherwise.
In order to use concurrent operations, the user must provide a reference to a `SpatialLockDataStructure_3` In order to use concurrent operations, the user must provide a
instance via the constructor or `set_lock_data_structure`. reference to a `SurjectiveLockDataStructure`
instance via the constructor or `Triangulation_3::set_lock_data_structure`.
If `TriangulationDataStructure_3::Concurrency_tag` is `Parallel_tag`, some operations, If `TriangulationDataStructure_3::Concurrency_tag` is `Parallel_tag`, some operations,
such as insertion/removal of a range of points, are performed in parallel. See such as insertion/removal of a range of points, are performed in parallel. See
@ -47,8 +49,8 @@ the documentation of the operations for more details.
\sa `CGAL::Delaunay_triangulation_3` \sa `CGAL::Delaunay_triangulation_3`
*/ */
template< typename RegularTriangulationTraits_3, typename TriangulationDataStructure_3, typename SpatialLockDataStructure_3 > template< typename RegularTriangulationTraits_3, typename TriangulationDataStructure_3, typename SurjectiveLockDataStructure >
class Regular_triangulation_3 : public Triangulation_3<RegularTriangulationTraits_3,TriangulationDataStructure_3,SpatialLockDataStructure_3> { class Regular_triangulation_3 : public Triangulation_3<RegularTriangulationTraits_3,TriangulationDataStructure_3,SurjectiveLockDataStructure> {
public: public:
/// \name Types /// \name Types
@ -68,7 +70,7 @@ typedef RegularTriangulationTraits_3::Weighted_point_3 Weighted_point;
/*! /*!
*/ */
typedef SpatialLockDataStructure_3 Lock_data_structure; typedef SurjectiveLockDataStructure Lock_data_structure;
/// @} /// @}
@ -83,12 +85,12 @@ must be provided if concurrency is enabled.
*/ */
Regular_triangulation_3 Regular_triangulation_3
(const RegularTriangulationTraits_3 & traits = RegularTriangulationTraits_3(), (const RegularTriangulationTraits_3 & traits = RegularTriangulationTraits_3(),
SpatialLockDataStructure_3 *lock_ds = NULL); Lock_data_structure *lock_ds = NULL);
/*! /*!
Copy constructor. Copy constructor.
The pointer to the lock data structure is not copied. Thus, the copy won't be The pointer to the lock data structure is not copied. Thus, the copy won't be
concurrency-safe as long as the user has not called `set_lock_data_structure`. concurrency-safe as long as the user has not called `Triangulation_3::set_lock_data_structure`.
*/ */
Regular_triangulation_3 Regular_triangulation_3
(const Regular_triangulation_3 & rt1); (const Regular_triangulation_3 & rt1);
@ -101,14 +103,14 @@ traits class argument and calling `insert(first,last)`.
template < class InputIterator > template < class InputIterator >
Regular_triangulation_3 (InputIterator first, InputIterator last, Regular_triangulation_3 (InputIterator first, InputIterator last,
const RegularTriangulationTraits_3& traits = RegularTriangulationTraits_3(), const RegularTriangulationTraits_3& traits = RegularTriangulationTraits_3(),
SpatialLockDataStructure_3 *lock_ds = NULL); Lock_data_structure *lock_ds = NULL);
/*! /*!
Same as before, with last two parameters in reverse order. Same as before, with last two parameters in reverse order.
*/ */
template < class InputIterator > template < class InputIterator >
Regular_triangulation_3 (InputIterator first, InputIterator last, Regular_triangulation_3 (InputIterator first, InputIterator last,
SpatialLockDataStructure_3 *lock_ds, Lock_data_structure *lock_ds,
const RegularTriangulationTraits_3& traits = RegularTriangulationTraits_3()); const RegularTriangulationTraits_3& traits = RegularTriangulationTraits_3());
/// @} /// @}

View File

@ -12,14 +12,16 @@ of points.
\tparam TriangulationDataStructure_3 is the triangulation data structure. \tparam TriangulationDataStructure_3 is the triangulation data structure.
It has the default value `Triangulation_data_structure_3< Triangulation_vertex_base_3<TriangulationTraits_3>,Triangulation_cell_base_3<TriangulationTraits_3> >`. It has the default value `Triangulation_data_structure_3< Triangulation_vertex_base_3<TriangulationTraits_3>,Triangulation_cell_base_3<TriangulationTraits_3> >`.
\tparam SpatialLockDataStructure_3 is an optional parameter to specify the type of the spatial lock data structure. \tparam SurjectiveLockDataStructure is an optional parameter to specify the type of the spatial lock data structure.
It is only used if the triangulation data structure used is concurrency-safe (i.e.\ when It is only used if the triangulation data structure used is concurrency-safe (i.e.\ when
TriangulationDataStructure_3::Concurrency_tag is Parallel_tag). TriangulationDataStructure_3::Concurrency_tag is Parallel_tag).
It must be a model of the `SpatialLockDataStructure_3` concept. It must be a model of the `SurjectiveLockDataStructure` concept,
The default value is `Spatial_grid_lock_data_structure_3<Tag_priority_blocking>` if with `Object` being a `Point`.
The default value is `Spatial_lock_grid_3<Tag_priority_blocking>` if
the triangulation data structure is concurrency-safe, and `void` otherwise. the triangulation data structure is concurrency-safe, and `void` otherwise.
In order to use concurrent operations, the user must provide a reference to a `SpatialLockDataStructure_3` In order to use concurrent operations, the user must provide a
instance via the constructor or `set_lock_data_structure`. reference to a `SurjectiveLockDataStructure`
instance via the constructor or `Triangulation_3::set_lock_data_structure`.
\cgalHeading{Traversal of the Triangulation} \cgalHeading{Traversal of the Triangulation}
@ -31,7 +33,7 @@ that allow one to traverse it (completely or partially).
*/ */
template< typename TriangulationTraits_3, typename TriangulationDataStructure_3, template< typename TriangulationTraits_3, typename TriangulationDataStructure_3,
typename SpatialLockDataStructure_3 > typename SurjectiveLockDataStructure >
class Triangulation_3 : public Triangulation_utils_3 { class Triangulation_3 : public Triangulation_utils_3 {
public: public:
@ -54,6 +56,11 @@ typedef TriangulationDataStructure_3 Triangulation_data_structure;
/*! /*!
*/
typedef SurjectiveLockDataStructure Lock_data_structure;
/*!
*/ */
typedef TriangulationTraits_3 Geom_traits; typedef TriangulationTraits_3 Geom_traits;
@ -222,19 +229,19 @@ must be provided if concurrency is enabled.
*/ */
Triangulation_3 Triangulation_3
(const TriangulationTraits_3 & traits = TriangulationTraits_3(), (const TriangulationTraits_3 & traits = TriangulationTraits_3(),
SpatialLockDataStructure_3 *lock_ds = NULL); Lock_data_structure *lock_ds = NULL);
/*! /*!
Same as the previous one, but with parameters in reverse order. Same as the previous one, but with parameters in reverse order.
*/ */
Triangulation_3 Triangulation_3
(SpatialLockDataStructure_3 *lock_ds = NULL, (Lock_data_structure *lock_ds = NULL,
const TriangulationTraits_3 & traits = TriangulationTraits_3()); const TriangulationTraits_3 & traits = TriangulationTraits_3());
/*! /*!
Copy constructor. All vertices and faces are duplicated. Copy constructor. All vertices and faces are duplicated.
The pointer to the lock data structure is not copied. Thus, the copy won't be The pointer to the lock data structure is not copied. Thus, the copy won't be
concurrency-safe as long as the user has not call `set_lock_data_structure`. concurrency-safe as long as the user has not call `Triangulation_3::set_lock_data_structure`.
*/ */
Triangulation_3 (const Triangulation_3 & tr); Triangulation_3 (const Triangulation_3 & tr);
@ -245,7 +252,7 @@ traits class argument and calling `insert(first,last)`.
template < class InputIterator> template < class InputIterator>
Triangulation_3 (InputIterator first, InputIterator last, Triangulation_3 (InputIterator first, InputIterator last,
const TriangulationTraits_3 & traits = TriangulationTraits_3(), const TriangulationTraits_3 & traits = TriangulationTraits_3(),
SpatialLockDataStructure_3 *lock_ds = NULL); Lock_data_structure *lock_ds = NULL);
/// @} /// @}
@ -1406,7 +1413,7 @@ ostream& operator<< (ostream& os, const Triangulation_3 &t);
/*! /*!
Set the pointer to the lock data structure. Set the pointer to the lock data structure.
*/ */
void set_lock_data_structure(SpatialLockDataStructure_3 *lock_ds) const; void set_lock_data_structure(Lock_data_structure *lock_ds) const;
/// @} /// @}

View File

@ -83,10 +83,10 @@ is opposite to the vertex with the same index. See
### Main Classes ### ### Main Classes ###
- `CGAL::Triangulation_3<TriangulationTraits_3,TriangulationDataStructure_3,SpatialLockDataStructure_3>` - `CGAL::Triangulation_3<TriangulationTraits_3,TriangulationDataStructure_3,SurjectiveLockDataStructure>`
- `CGAL::Delaunay_triangulation_3<DelaunayTriangulationTraits_3,TriangulationDataStructure_3,LocationPolicy,SpatialLockDataStructure_3>` - `CGAL::Delaunay_triangulation_3<DelaunayTriangulationTraits_3,TriangulationDataStructure_3,LocationPolicy,SurjectiveLockDataStructure>`
- `CGAL::Triangulation_hierarchy_3<Tr>` - `CGAL::Triangulation_hierarchy_3<Tr>`
- `CGAL::Regular_triangulation_3<RegularTriangulationTraits_3,TriangulationDataStructure_3,SpatialLockDataStructure_3>` - `CGAL::Regular_triangulation_3<RegularTriangulationTraits_3,TriangulationDataStructure_3,SurjectiveLockDataStructure>`
- `CGAL::Triangulation_cell_base_3<TriangulationTraits_3, TriangulationDSCellBase_3>` - `CGAL::Triangulation_cell_base_3<TriangulationTraits_3, TriangulationDSCellBase_3>`
- `CGAL::Triangulation_cell_base_with_info_3<Info, TriangulationTraits_3, TriangulationCellBase_3>` - `CGAL::Triangulation_cell_base_with_info_3<Info, TriangulationTraits_3, TriangulationCellBase_3>`
- `CGAL::Triangulation_cell_base_with_circumcenter_3<DelaunayTriangulationTraits_3, TriangulationCellBase_3>` - `CGAL::Triangulation_cell_base_with_circumcenter_3<DelaunayTriangulationTraits_3, TriangulationCellBase_3>`

View File

@ -225,9 +225,9 @@ triangulation class, described in Section \ref Triangulation3seclocpol.
Optionally, the main Delaunay and regular triangulations algorithms (insert, remove) Optionally, the main Delaunay and regular triangulations algorithms (insert, remove)
support multi-core shared-memory architectures to take advantage of available parallelism. support multi-core shared-memory architectures to take advantage of available parallelism.
For this purpose, a model of the concept `SpatialLockDataStructure_3` can be For this purpose, a model of the concept `SurjectiveLockDataStructure` can be
given as fourth template parameter; it defaults to given as fourth template parameter; it defaults to
`Spatial_grid_lock_data_structure_3`. This data structure `Spatial_lock_grid_3`. This data structure
allows to lock points with coordinates (x, y, z) in a 3D domain. When a thread owns the allows to lock points with coordinates (x, y, z) in a 3D domain. When a thread owns the
lock on a point, no other thread can lock this point. Locking a facet (resp. a cell) lock on a point, no other thread can lock this point. Locking a facet (resp. a cell)
boils down to locking all its 3 (resp. 4) incident vertices. boils down to locking all its 3 (resp. 4) incident vertices.
@ -417,14 +417,14 @@ Section \ref TDS3secdesign "Software Design" provides more detailed information.
Parallel algorithms of `Delaunay_triangulation_3` and Parallel algorithms of `Delaunay_triangulation_3` and
`Regular_triangulation_3` are enabled `Regular_triangulation_3` are enabled
if the `TriangulationDataStructure_3::Concurrency_tag` type is `Parallel_tag` and a if the `TriangulationDataStructure_3::Concurrency_tag` type is `Parallel_tag` and a
reference to a `SpatialLockDataStructure_3` instance is provided via the constructor or reference to a lock data structure instance is provided via the constructor or
by using `set_lock_data_structure`. Note that the parallel Delaunay by using `Triangulation_3::set_lock_data_structure`. Note that the parallel Delaunay
triangulation must use the default compact location policy (and not the fast triangulation must use the default compact location policy (and not the fast
one). one).
Parallel algorithms require the program to be linked against the Intel TBB library. Parallel algorithms require the program to be linked against the Intel TBB library.
To control the number of threads used, the user may use the tbb::task_scheduler_init class. To control the number of threads used, the user may use the tbb::task_scheduler_init class.
See TBB documentation for more details. See the TBB documentation for more details.
\section Triangulation3secexamples Examples \section Triangulation3secexamples Examples

View File

@ -51,7 +51,7 @@
#include <CGAL/Iterator_project.h> #include <CGAL/Iterator_project.h>
#include <CGAL/Default.h> #include <CGAL/Default.h>
#include <CGAL/Spatial_grid_lock_data_structure_3.h> #include <CGAL/Spatial_lock_grid_3.h>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/random/linear_congruential.hpp> #include <boost/random/linear_congruential.hpp>
@ -192,10 +192,9 @@ template <typename Lock_data_structure_>
class Triangulation_3_base<Parallel_tag, Lock_data_structure_> class Triangulation_3_base<Parallel_tag, Lock_data_structure_>
{ {
public: public:
// If Lock_data_structure_ = Default => use Spatial_grid_lock_data_structure_3 // If Lock_data_structure_ = Default => use Spatial_lock_grid_3
typedef typename Default::Get< typedef typename Default::Get<
Lock_data_structure_, Lock_data_structure_, Spatial_lock_grid_3<Tag_priority_blocking> >
Spatial_grid_lock_data_structure_3<Tag_priority_blocking> >
::type Lock_data_structure; ::type Lock_data_structure;
protected: protected:

View File

@ -458,9 +458,8 @@ public:
template <typename Cell_handle> template <typename Cell_handle>
bool is_cell_locked_by_this_thread(const Cell_handle &cell_handle) const bool is_cell_locked_by_this_thread(const Cell_handle &cell_handle) const
{ {
CGAL::Spatial_grid_lock_data_structure_3< CGAL::Spatial_lock_grid_3<Tag_priority_blocking> *lock_ds =
Tag_priority_blocking> *lock_ds = CGAL::Spatial_lock_grid_3::get_global_lock_ds();
CGAL::Spatial_grid_lock_data_structure_3::get_global_lock_ds();
bool locked = true; bool locked = true;
if (lock_ds) if (lock_ds)
{ {