Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended Non-intrusive Serialization to Ease Usage for Library Developers #1680

Merged
merged 9 commits into from Jul 25, 2015

Conversation

Projects
None yet
3 participants
@gentryx
Copy link
Member

commented Jul 21, 2015

The intrusive serialization factory requires a class to ship a serialize() function. This is not always desirable, e.g. if this function is automatically generated externally. The non-intrusive serialization factory requires users to manually register all template instantiations, which is impossible to guarantee in the context of generic libraries (or: a user burden, but that's essentially the same).

The new "semi-intrusive" code adds infrastructure to relieve library developers from having to manually register all template instantiations. This requires a minute change (intrusion) to registered templates, but serialize() can still be put outside.

gentryx added some commits Jul 21, 2015

Refactoring name lookup/registration in polymorphic_nonintrusive_factory
get_serialization_name() used to be a function. This prevented us from registering templates for which we'd need partial specializations.
added new semi-intrusive option for registering template classes
pro: doesn't require manual registration of all template instatiations (as the current non-intrusive code does), can use external serialization functions (unlike the intrusive code)
con: still one macro needs to be instantiated within user classes
}}} \
template hpx::serialization::detail::register_class<Class> \
hpx::serialization::detail::register_class<Class>::instance; \
/**/
#define HPX_SERIALIZATION_REGISTER_CLASS_NAME_TEMPLATE(Parameters, Template, Name) \
namespace hpx { namespace serialization { namespace detail { \
Parameters \

This comment has been minimized.

Copy link
@sithhell

sithhell Jul 22, 2015

Member

This is missing HPX_ALWAYS_EXPORT

This comment has been minimized.

Copy link
@gentryx

gentryx Jul 22, 2015

Author Member

fixed, thanks!

This comment has been minimized.

Copy link
@hkaiser

hkaiser Jul 22, 2015

Member

Unfortunately, the HPX_ALWAYS_EXPORT has to be placed in between the 'struct' keyword and the type name. Visual Studio is picky about this (this is true for type definitions only, for functions it still expect it to be in front of everything).

This comment has been minimized.

Copy link
@hkaiser

hkaiser Jul 22, 2015

Member

Thanks Andreas. AFAICS, those others you moved were not misplaced before as they had been applied to functions, not type definitions.

#define HPX_SERIALIZATION_REGISTER_CLASS(Class) \
HPX_SERIALIZATION_REGISTER_CLASS_NAME(Class, BOOST_PP_STRINGIZE(Class)) \

/**/
#define HPX_SERIALIZATION_REGISTER_CLASS_TEMPLATE(Parameters, Template) \

This comment has been minimized.

Copy link
@sithhell

sithhell Jul 22, 2015

Member

Unfortunately, this will break when having more than one template parameter, see here:
http://melpon.org/wandbox/permlink/QSsUVv9Q6av1XMty

An alternative would be to only pass the template arguments in the form of (typename A, typename B) and then expand it to template <HPX_UTIL_STRIP(Parameters)>

This comment has been minimized.

Copy link
@gentryx

gentryx Jul 22, 2015

Author Member

Fixed, thanks!

@gentryx gentryx referenced this pull request Jul 22, 2015

Closed

HPX Backend Restoration Tracer #4

26 of 26 tasks complete
@gentryx

This comment has been minimized.

Copy link
Member Author

commented Jul 22, 2015

@hkaiser Thanks, I've moved the HPX_ALWAYS_EXPORT macros (including those which were previously misplaced in existing code ;-) )

@hkaiser

This comment has been minimized.

Copy link
Member

commented Jul 22, 2015

LGTM

hkaiser added a commit that referenced this pull request Jul 25, 2015

Merge pull request #1680 from gentryx/master
Extended Non-intrusive Serialization to Ease Usage for Library Developers

@hkaiser hkaiser merged commit 9a29a4d into STEllAR-GROUP:master Jul 25, 2015

1 check passed

ci/circleci Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.