mirror of https://github.com/CGAL/cgal
Re-use existing time stamps
When a `Vertex` or a `Cell` is recycled by the `Compact_container`, re-use the existing time stamp instead of increment it. That will avoid that the pointee of a handle has a changing timestamp.
This commit is contained in:
parent
706b53b2c2
commit
0757cfaeb0
|
|
@ -261,7 +261,6 @@ public:
|
||||||
, next_intrusive_()
|
, next_intrusive_()
|
||||||
, previous_intrusive_()
|
, previous_intrusive_()
|
||||||
#endif
|
#endif
|
||||||
, time_stamp_(-1)
|
|
||||||
, surface_center_index_table_()
|
, surface_center_index_table_()
|
||||||
, sliver_value_(FT(0.))
|
, sliver_value_(FT(0.))
|
||||||
, subdomain_index_()
|
, subdomain_index_()
|
||||||
|
|
@ -298,7 +297,6 @@ public:
|
||||||
, next_intrusive_()
|
, next_intrusive_()
|
||||||
, previous_intrusive_()
|
, previous_intrusive_()
|
||||||
#endif
|
#endif
|
||||||
, time_stamp_(-1)
|
|
||||||
, surface_center_index_table_()
|
, surface_center_index_table_()
|
||||||
, sliver_value_(FT(0.))
|
, sliver_value_(FT(0.))
|
||||||
, subdomain_index_()
|
, subdomain_index_()
|
||||||
|
|
@ -323,7 +321,6 @@ public:
|
||||||
, next_intrusive_()
|
, next_intrusive_()
|
||||||
, previous_intrusive_()
|
, previous_intrusive_()
|
||||||
#endif
|
#endif
|
||||||
, time_stamp_(-1)
|
|
||||||
, surface_center_index_table_()
|
, surface_center_index_table_()
|
||||||
, sliver_value_(FT(0.))
|
, sliver_value_(FT(0.))
|
||||||
, subdomain_index_()
|
, subdomain_index_()
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,6 @@ public:
|
||||||
, next_intrusive_()
|
, next_intrusive_()
|
||||||
, previous_intrusive_()
|
, previous_intrusive_()
|
||||||
#endif
|
#endif
|
||||||
, time_stamp_(-1)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Mesh_cell_base_3 (Vertex_handle v0,
|
Mesh_cell_base_3 (Vertex_handle v0,
|
||||||
|
|
@ -164,7 +163,6 @@ public:
|
||||||
, next_intrusive_()
|
, next_intrusive_()
|
||||||
, previous_intrusive_()
|
, previous_intrusive_()
|
||||||
#endif
|
#endif
|
||||||
, time_stamp_(-1)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Mesh_cell_base_3 (Vertex_handle v0,
|
Mesh_cell_base_3 (Vertex_handle v0,
|
||||||
|
|
@ -183,7 +181,6 @@ public:
|
||||||
, next_intrusive_()
|
, next_intrusive_()
|
||||||
, previous_intrusive_()
|
, previous_intrusive_()
|
||||||
#endif
|
#endif
|
||||||
, time_stamp_(-1)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// Default copy constructor and assignment operator are ok
|
// Default copy constructor and assignment operator are ok
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,6 @@ public:
|
||||||
, next_intrusive_()
|
, next_intrusive_()
|
||||||
, previous_intrusive_()
|
, previous_intrusive_()
|
||||||
#endif //CGAL_INTRUSIVE_LIST
|
#endif //CGAL_INTRUSIVE_LIST
|
||||||
, time_stamp_(-1)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// Default copy constructor and assignment operator are ok
|
// Default copy constructor and assignment operator are ok
|
||||||
|
|
|
||||||
|
|
@ -921,6 +921,7 @@ void Compact_container<T, Allocator, Increment_policy, TimeStamper>::allocate_ne
|
||||||
for (size_type i = block_size; i >= 1; --i)
|
for (size_type i = block_size; i >= 1; --i)
|
||||||
{
|
{
|
||||||
EraseCounterStrategy::set_erase_counter(*(new_block + i), 0);
|
EraseCounterStrategy::set_erase_counter(*(new_block + i), 0);
|
||||||
|
time_stamper->initialize_time_stamp(new_block + i);
|
||||||
put_on_free_list(new_block + i);
|
put_on_free_list(new_block + i);
|
||||||
}
|
}
|
||||||
// We insert this new block at the end.
|
// We insert this new block at the end.
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,14 @@ struct Time_stamper
|
||||||
Time_stamper(const Time_stamper& ts)
|
Time_stamper(const Time_stamper& ts)
|
||||||
: time_stamp_(ts.time_stamp_) {}
|
: time_stamp_(ts.time_stamp_) {}
|
||||||
|
|
||||||
|
static void initialize_time_stamp(T* pt) {
|
||||||
|
pt->set_time_stamp(std::size_t(-1));
|
||||||
|
}
|
||||||
|
|
||||||
void set_time_stamp(T* pt) {
|
void set_time_stamp(T* pt) {
|
||||||
pt->set_time_stamp(time_stamp_++);
|
if(pt->time_stamp() == std::size_t(-1))
|
||||||
|
pt->set_time_stamp(time_stamp_++);
|
||||||
|
// else: the time stamp is re-used
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -66,6 +72,9 @@ public:
|
||||||
return p_t1 < p_t2;
|
return p_t1 < p_t2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void initialize_time_stamp(T*) {
|
||||||
|
}
|
||||||
|
|
||||||
static std::size_t hash_value(const T* p) {
|
static std::size_t hash_value(const T* p) {
|
||||||
return reinterpret_cast<std::size_t>(p)/sizeof(T);
|
return reinterpret_cast<std::size_t>(p)/sizeof(T);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue