renamed serialize_node_pointer as serialize_tracked_address (editorial)

This commit is contained in:
joaquintides
2023-08-25 11:34:39 +02:00
parent b0195297f0
commit d007a5a7bd
5 changed files with 50 additions and 52 deletions

View File

@ -114,7 +114,7 @@ to normal separate chaining implementations.
*/
#include <boost/unordered/detail/prime_fmod.hpp>
#include <boost/unordered/detail/serialize_node_pointer.hpp>
#include <boost/unordered/detail/serialize_tracked_address.hpp>
#include <boost/core/addressof.hpp>
#include <boost/core/allocator_access.hpp>
@ -295,8 +295,8 @@ namespace boost {
Archive& ar, grouped_bucket_iterator const& x)
{
// requires: not at end() position
track_node_pointer(ar, x.p);
track_node_pointer(ar, x.pbg);
track_address(ar, x.p);
track_address(ar, x.pbg);
}
friend class boost::serialization::access;
@ -305,8 +305,8 @@ namespace boost {
void serialize(Archive& ar,unsigned int)
{
// requires: not at end() position
serialize_node_pointer(ar, p);
serialize_node_pointer(ar, pbg);
serialize_tracked_address(ar, p);
serialize_tracked_address(ar, pbg);
}
};

View File

@ -17,7 +17,7 @@
#include <boost/config/workaround.hpp>
#include <boost/core/serialization.hpp>
#include <boost/unordered/detail/foa/core.hpp>
#include <boost/unordered/detail/serialize_node_pointer.hpp>
#include <boost/unordered/detail/serialize_tracked_address.hpp>
#include <cstddef>
#include <iterator>
#include <memory>
@ -201,8 +201,8 @@ private:
friend void serialization_track(Archive& ar,const table_iterator& x)
{
if(x.p){
track_node_pointer(ar,x.pc);
track_node_pointer(ar,x.p);
track_address(ar,x.pc);
track_address(ar,x.p);
}
}
@ -212,8 +212,8 @@ private:
void serialize(Archive& ar,unsigned int)
{
if(!p)pc=nullptr;
serialize_node_pointer(ar,pc);
serialize_node_pointer(ar,p);
serialize_tracked_address(ar,pc);
serialize_tracked_address(ar,p);
}
unsigned char *pc=nullptr;

View File

@ -48,7 +48,7 @@
#include <boost/type_traits/make_void.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/unordered/detail/fca.hpp>
#include <boost/unordered/detail/serialize_node_pointer.hpp>
#include <boost/unordered/detail/serialize_tracked_address.hpp>
#include <boost/unordered/detail/type_traits.hpp>
#include <boost/unordered/detail/fwd.hpp>
#include <boost/utility/addressof.hpp>
@ -1710,7 +1710,7 @@ namespace boost {
friend void serialization_track(Archive& ar, const iterator& x)
{
if(x.p){
track_node_pointer(ar, x.p);
track_address(ar, x.p);
serialization_track(ar, x.itb);
}
}
@ -1721,7 +1721,7 @@ namespace boost {
void serialize(Archive& ar,unsigned int)
{
if(!p) itb = bucket_iterator();
serialize_node_pointer(ar, p);
serialize_tracked_address(ar, p);
ar & core::make_nvp("bucket_iterator", itb);
}
};
@ -1819,7 +1819,7 @@ namespace boost {
friend void serialization_track(Archive& ar, const c_iterator& x)
{
if(x.p){
track_node_pointer(ar, x.p);
track_address(ar, x.p);
serialization_track(ar, x.itb);
}
}
@ -1830,7 +1830,7 @@ namespace boost {
void serialize(Archive& ar,unsigned int)
{
if(!p) itb = bucket_iterator();
serialize_node_pointer(ar, p);
serialize_tracked_address(ar, p);
ar & core::make_nvp("bucket_iterator", itb);
}
};

View File

@ -29,12 +29,12 @@ namespace detail{
* through the following protocol:
* - At saving time, for each iterator it in [x.begin(),x.end()),
* serialization_track(ar,it) is ADL-called to instruct the archive to
* track the addresses of the iterator's associated node(s) via
* track_node_pointer().
* track the positions internally pointed to by the iterator via
* track_address().
* - At loading time, these addresses are mapped to those of the equivalent
* reconstructed nodes using again serialization_track(ar,it).
* reconstructed positions using again serialization_track(ar,it).
* - Serializing an iterator reduces to serializing pointers to previously
* tracked nodes via serialize_node_pointer().
* tracked addresses via serialize_address().
*/
template<typename Iterator>

View File

@ -6,8 +6,8 @@
* See https://www.boost.org/libs/unordered for library home page.
*/
#ifndef BOOST_UNORDERED_DETAIL_SERIALIZE_NODE_POINTER_HPP
#define BOOST_UNORDERED_DETAIL_SERIALIZE_NODE_POINTER_HPP
#ifndef BOOST_UNORDERED_DETAIL_SERIALIZE_TRACKED_ADDRESS_HPP
#define BOOST_UNORDERED_DETAIL_SERIALIZE_TRACKED_ADDRESS_HPP
#include <boost/core/pointer_traits.hpp>
#include <boost/core/serialization.hpp>
@ -20,19 +20,19 @@ namespace boost{
namespace unordered{
namespace detail{
/* Node pointer serialization to support iterator serialization as described
/* Tracked address serialization to support iterator serialization as described
* in serialize_container.hpp. The underlying technique is to reinterpret_cast
* Node pointers to serialization_tracker<Node> pointers, which, when
* dereferenced and serialized, do not emit any serialization payload to the
* T pointers to serialization_tracker<T> pointers, which, when dereferenced
* and serialized, do not emit any serialization payload to the
* archive, but activate object tracking on the relevant addresses for later
* use with serialize_node_pointer().
* use with serialize_tracked_address().
*/
template<typename Node>
template<typename T>
struct serialization_tracker
{
/* An attempt to construct a serialization_tracker means a stray address
* in the archive, that is, one without a previously tracked node.
* in the archive, that is, one without a previously tracked address.
*/
serialization_tracker(){throw_exception(bad_archive_exception());}
@ -40,60 +40,58 @@ struct serialization_tracker
void serialize(Archive&,unsigned int){} /* no data emitted */
};
template<typename Archive,typename NodePtr>
void track_node_pointer(Archive& ar,NodePtr p)
template<typename Archive,typename Ptr>
void track_address(Archive& ar,Ptr p)
{
typedef typename boost::pointer_traits<NodePtr> ptr_traits;
typedef typename boost::pointer_traits<Ptr> ptr_traits;
typedef typename boost::remove_const<
typename ptr_traits::element_type>::type node_type;
typename ptr_traits::element_type>::type element_type;
if(p){
ar&core::make_nvp(
"node",
*reinterpret_cast<serialization_tracker<node_type>*>(
const_cast<node_type*>(
"address",
*reinterpret_cast<serialization_tracker<element_type>*>(
const_cast<element_type*>(
boost::to_address(p))));
}
}
template<typename Archive,typename NodePtr>
void serialize_node_pointer(
Archive& ar,NodePtr& p,boost::true_type /* save */)
template<typename Archive,typename Ptr>
void serialize_tracked_address(Archive& ar,Ptr& p,boost::true_type /* save */)
{
typedef typename boost::pointer_traits<NodePtr> ptr_traits;
typedef typename boost::pointer_traits<Ptr> ptr_traits;
typedef typename boost::remove_const<
typename ptr_traits::element_type>::type node_type;
typedef serialization_tracker<node_type> tracker;
typename ptr_traits::element_type>::type element_type;
typedef serialization_tracker<element_type> tracker;
tracker* pt=
const_cast<tracker*>(
reinterpret_cast<const tracker*>(
const_cast<const node_type*>(
const_cast<const element_type*>(
boost::to_address(p))));
ar<<core::make_nvp("pointer",pt);
}
template<typename Archive,typename NodePtr>
void serialize_node_pointer(
Archive& ar,NodePtr& p,boost::false_type /* load */)
template<typename Archive,typename Ptr>
void serialize_tracked_address(Archive& ar,Ptr& p,boost::false_type /* load */)
{
typedef typename boost::pointer_traits<NodePtr> ptr_traits;
typedef typename boost::pointer_traits<Ptr> ptr_traits;
typedef typename boost::remove_const<
typename ptr_traits::element_type>::type node_type;
typedef serialization_tracker<node_type> tracker;
typename ptr_traits::element_type>::type element_type;
typedef serialization_tracker<element_type> tracker;
tracker* pt;
ar>>core::make_nvp("pointer",pt);
node_type* pn=const_cast<node_type*>(
reinterpret_cast<const node_type*>(
element_type* pn=const_cast<element_type*>(
reinterpret_cast<const element_type*>(
const_cast<const tracker*>(pt)));
p=pn?ptr_traits::pointer_to(*pn):0;
}
template<typename Archive,typename NodePtr>
void serialize_node_pointer(Archive& ar,NodePtr& p)
template<typename Archive,typename Ptr>
void serialize_tracked_address(Archive& ar,Ptr& p)
{
serialize_node_pointer(
serialize_tracked_address(
ar,p,
boost::integral_constant<bool,Archive::is_saving::value>());
}