Skip to content

Commit

Permalink
Merge branch 'Mesh_3-fix_compilation_with_tbb43-GF' into releases/CGA…
Browse files Browse the repository at this point in the history
…L-4.5-branch

fix the compilation of Mesh_3 for TBB 4.3

Approved by the release manager
  • Loading branch information
janetournois committed Dec 19, 2014
2 parents 5dbfeec + 90a74c1 commit 0ee08ef
Showing 1 changed file with 5 additions and 60 deletions.
65 changes: 5 additions & 60 deletions STL_Extension/include/CGAL/Spatial_lock_grid_3.h
Expand Up @@ -33,7 +33,6 @@
# include <thread>
#endif
#include <tbb/enumerable_thread_specific.h>
#include <tbb/recursive_mutex.h>

#include <algorithm>
#include <vector>
Expand All @@ -42,7 +41,6 @@ namespace CGAL {

struct Tag_no_lock {};
struct Tag_non_blocking {};
struct Tag_non_blocking_with_mutexes {};
struct Tag_priority_blocking {};

//*****************************************************************************
Expand Down Expand Up @@ -527,6 +525,11 @@ class Spatial_lock_grid_3<Tag_priority_blocking>
int num_cells =
num_grid_cells_per_axis*num_grid_cells_per_axis*num_grid_cells_per_axis;
m_grid.resize(num_cells);
// Explicitly initialize the atomics
std::vector<tbb::atomic<unsigned int> >::iterator it = m_grid.begin();
std::vector<tbb::atomic<unsigned int> >::iterator it_end = m_grid.end();
for ( ; it != it_end ; ++it)
*it = 0;
}

/// Destructor
Expand Down Expand Up @@ -606,64 +609,6 @@ class Spatial_lock_grid_3<Tag_priority_blocking>
TLS_thread_uint_ids m_tls_thread_ids;
};

//*****************************************************************************
// class Spatial_lock_grid_3<Tag_non_blocking_with_mutexes>
// Note: undocumented, for testing only...
//*****************************************************************************

template <>
class Spatial_lock_grid_3<Tag_non_blocking_with_mutexes>
: public Spatial_lock_grid_base_3<
Spatial_lock_grid_3<Tag_non_blocking_with_mutexes> >
{
typedef Spatial_lock_grid_base_3<
Spatial_lock_grid_3<Tag_non_blocking_with_mutexes> > Base;

public:
// Constructors
Spatial_lock_grid_3(const Bbox_3 &bbox, int num_grid_cells_per_axis)
: Base(bbox, num_grid_cells_per_axis)
{
int num_cells =
num_grid_cells_per_axis*num_grid_cells_per_axis*num_grid_cells_per_axis;
m_grid.resize(num_cells);
}

/// Destructor
~Spatial_lock_grid_3()
{
}

bool is_cell_locked_impl(int cell_index)
{
bool locked = m_grid[cell_index].try_lock();
if (locked)
m_grid[cell_index].unlock();
return !locked;
}

template <bool no_spin>
bool try_lock_cell_impl(int cell_index)
{
bool success = m_grid[cell_index].try_lock();
if (success)
{
get_thread_local_grid()[cell_index] = true;
m_tls_locked_cells.local().push_back(cell_index);
}
return success;
}

void unlock_cell_impl(int cell_index)
{
m_grid[cell_index].unlock();
}

protected:

std::vector<tbb::recursive_mutex> m_grid;
};

} //namespace CGAL

#else // !CGAL_LINKED_WITH_TBB
Expand Down

0 comments on commit 0ee08ef

Please sign in to comment.