Skip to content

Commit

Permalink
Making some traits constexpr instead of ALWAYS_EXPORT
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Feb 7, 2018
1 parent 6498068 commit 1e40175
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 58 deletions.
14 changes: 4 additions & 10 deletions hpx/runtime/actions/action_priority.hpp
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2015 Hartmut Kaiser
// Copyright (c) 2007-2018 Hartmut Kaiser
// Copyright (c) 2011 Bryce Lelbach
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand All @@ -15,17 +15,11 @@
namespace hpx { namespace actions
{
template <typename Action>
threads::thread_priority action_priority()
HPX_CONSTEXPR threads::thread_priority action_priority()
{
typedef typename hpx::traits::extract_action<Action>::type action_type_;
threads::thread_priority priority =
static_cast<threads::thread_priority>(
traits::action_priority<action_type_>::value);
// The mapping to 'normal' is now done at the last possible moment in
// the scheduler.
// if (priority == threads::thread_priority_default)
// priority = threads::thread_priority_normal;
return priority;
return static_cast<threads::thread_priority>(
traits::action_priority<action_type_>::value);
}
}}

Expand Down
16 changes: 6 additions & 10 deletions hpx/runtime/actions/action_support.hpp
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2017 Hartmut Kaiser
// Copyright (c) 2007-2018 Hartmut Kaiser
// Copyright (c) 2011 Bryce Lelbach
// Copyright (c) 2011 Thomas Heller
//
Expand Down Expand Up @@ -60,7 +60,7 @@ namespace hpx { namespace actions
namespace detail
{
template <typename Action>
char const* get_action_name()
HPX_CONSTEXPR char const* const get_action_name()
#ifndef HPX_HAVE_AUTOMATIC_SERIALIZATION_REGISTRATION
;
#else
Expand Down Expand Up @@ -109,7 +109,7 @@ namespace hpx { namespace actions
template <threads::thread_priority Priority>
struct thread_priority
{
static threads::thread_priority
HPX_CONSTEXPR static threads::thread_priority
call(threads::thread_priority priority)
{
if (priority == threads::thread_priority_default)
Expand All @@ -123,13 +123,9 @@ namespace hpx { namespace actions
template <>
struct thread_priority<threads::thread_priority_default>
{
static threads::thread_priority
HPX_CONSTEXPR static threads::thread_priority
call(threads::thread_priority priority)
{
// The mapping to 'normal' is now done at the last possible moment
// in the scheduler.
// if (priority == threads::thread_priority_default)
// return threads::thread_priority_normal;
return priority;
}
};
Expand All @@ -141,7 +137,7 @@ namespace hpx { namespace actions
template <threads::thread_stacksize Stacksize>
struct thread_stacksize
{
static threads::thread_stacksize
HPX_CONSTEXPR static threads::thread_stacksize
call(threads::thread_stacksize stacksize)
{
if (stacksize == threads::thread_stacksize_default)
Expand All @@ -155,7 +151,7 @@ namespace hpx { namespace actions
template <>
struct thread_stacksize<threads::thread_stacksize_default>
{
static threads::thread_stacksize
HPX_CONSTEXPR static threads::thread_stacksize
call(threads::thread_stacksize stacksize)
{
if (stacksize == threads::thread_stacksize_default)
Expand Down
2 changes: 1 addition & 1 deletion hpx/runtime/actions/base_action.hpp
Expand Up @@ -60,7 +60,7 @@ namespace hpx { namespace actions

/// The function \a get_action_name returns the name of this action
/// (mainly used for debugging and logging purposes).
virtual char const* get_action_name() const = 0;
virtual char const* const get_action_name() const = 0;

/// The function \a get_action_type returns whether this action needs
/// to be executed in a new thread or directly.
Expand Down
16 changes: 6 additions & 10 deletions hpx/runtime/actions/basic_action.hpp
Expand Up @@ -842,10 +842,9 @@ namespace hpx { namespace serialization
#endif

#define HPX_DEFINE_GET_ACTION_NAME_(action, actionname) \
HPX_DEFINE_GET_ACTION_NAME_ITT(action, actionname) \
namespace hpx { namespace actions { namespace detail { \
template<> HPX_ALWAYS_EXPORT \
char const* get_action_name< action>() \
template <> \
HPX_CONSTEXPR char const* const get_action_name< action>() \
{ \
return HPX_PP_STRINGIZE(actionname); \
} \
Expand All @@ -861,7 +860,7 @@ namespace hpx { namespace serialization
HPX_REGISTER_ACTION_2(action, action) \
/**/
#define HPX_REGISTER_ACTION_2(action, actionname) \
HPX_DEFINE_GET_ACTION_NAME_(action, actionname) \
HPX_DEFINE_GET_ACTION_NAME_ITT(action, actionname) \
HPX_REGISTER_ACTION_INVOCATION_COUNT(action) \
HPX_REGISTER_PER_ACTION_DATA_COUNTER_TYPES(action) \
namespace hpx { namespace actions { \
Expand Down Expand Up @@ -896,12 +895,9 @@ namespace hpx { namespace serialization
#define HPX_REGISTER_ACTION_DECLARATION_NO_DEFAULT_GUID_ITT(action)
#endif

#define HPX_REGISTER_ACTION_DECLARATION_NO_DEFAULT_GUID(action) \
#define HPX_REGISTER_ACTION_DECLARATION_NO_DEFAULT_GUID(action, actionname) \
HPX_REGISTER_ACTION_DECLARATION_NO_DEFAULT_GUID_ITT(action) \
namespace hpx { namespace actions { namespace detail { \
template <> HPX_ALWAYS_EXPORT \
char const* get_action_name< action>(); \
}}} \
HPX_DEFINE_GET_ACTION_NAME_(action, actionname) \
HPX_REGISTER_ACTION_EXTERN_DECLARATION(action) \
\
namespace hpx { namespace traits { \
Expand All @@ -925,7 +921,7 @@ namespace hpx { namespace serialization
HPX_REGISTER_ACTION_DECLARATION_2(action, action) \
/**/
#define HPX_REGISTER_ACTION_DECLARATION_2(action, actionname) \
HPX_REGISTER_ACTION_DECLARATION_NO_DEFAULT_GUID(action) \
HPX_REGISTER_ACTION_DECLARATION_NO_DEFAULT_GUID(action, actionname) \
/**/

///////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion hpx/runtime/actions/basic_action_fwd.hpp
Expand Up @@ -26,7 +26,7 @@ namespace hpx { namespace actions
namespace detail
{
template <typename Action>
char const* get_action_name();
HPX_CONSTEXPR char const* const get_action_name();

#if HPX_HAVE_ITTNOTIFY != 0 && !defined(HPX_HAVE_APEX)
template <typename Action>
Expand Down
11 changes: 7 additions & 4 deletions hpx/runtime/actions/detail/action_factory.hpp
Expand Up @@ -64,8 +64,9 @@ namespace hpx { namespace actions { namespace detail

public:
register_action();

static base_action* create(bool);
register_action& instantiate();
HPX_CONSTEXPR register_action& instantiate();

static register_action instance;
};
Expand All @@ -91,13 +92,14 @@ namespace hpx { namespace actions { namespace detail
}

template <typename Action>
register_action<Action>& register_action<Action>::instantiate()
HPX_CONSTEXPR register_action<Action>&
register_action<Action>::instantiate()
{
return *this;
}

template <std::uint32_t Id>
HPX_ALWAYS_EXPORT std::string get_action_name_id();
HPX_CONSTEXPR char const* const get_action_name_id();

template <std::uint32_t Id>
struct add_constant_entry
Expand All @@ -107,6 +109,7 @@ namespace hpx { namespace actions { namespace detail

public:
add_constant_entry();

static add_constant_entry instance;
};

Expand All @@ -123,7 +126,7 @@ namespace hpx { namespace actions { namespace detail

#define HPX_REGISTER_ACTION_FACTORY_ID(Name, Id) \
namespace hpx { namespace actions { namespace detail { \
template <> HPX_ALWAYS_EXPORT std::string get_action_name_id< Id>() \
template <> HPX_CONSTEXPR char const* const get_action_name_id< Id>() \
{ \
return HPX_PP_STRINGIZE(Name); \
} \
Expand Down
2 changes: 1 addition & 1 deletion hpx/runtime/actions/transfer_base_action.hpp
Expand Up @@ -217,7 +217,7 @@ namespace hpx { namespace actions

/// The function \a get_action_name returns the name of this action
/// (mainly used for debugging and logging purposes).
char const* get_action_name() const override
char const* const get_action_name() const override
{
return detail::get_action_name<derived_type>();
}
Expand Down
33 changes: 17 additions & 16 deletions hpx/runtime/components/component_type.hpp
Expand Up @@ -100,27 +100,28 @@ namespace hpx { namespace components

/// The lower short word of the component type is the type of the component
/// exposing the actions.
inline component_type get_base_type(component_type t)
HPX_CONSTEXPR inline component_type get_base_type(component_type t)
{
return component_type(t & 0xFFFF);
}

/// The upper short word of the component is the actual component type
inline component_type get_derived_type(component_type t)
HPX_CONSTEXPR inline component_type get_derived_type(component_type t)
{
return component_type((t >> 16) & 0xFFFF);
}

/// A component derived from a base component exposing the actions needs to
/// have a specially formatted component type.
inline component_type
HPX_CONSTEXPR inline component_type
derived_component_type(component_type derived, component_type base)
{
return component_type(derived << 16 | base);
}

/// \brief Verify the two given component types are matching (compatible)
inline bool types_are_compatible(component_type lhs, component_type rhs)
HPX_CONSTEXPR inline bool types_are_compatible(component_type lhs,
component_type rhs)
{
// don't compare types if one of them is unknown
if (component_invalid == rhs || component_invalid == lhs)
Expand Down Expand Up @@ -174,21 +175,21 @@ namespace hpx { namespace components

// Returns the (unique) name for a given component
template <typename Component, typename Enable = void>
const char* get_component_name();
HPX_CONSTEXPR char const* const get_component_name();

// Returns the (unique) name of the base component. If there is none,
// nullptr is returned
template <typename Component, typename Enable = void>
const char* get_component_base_name();
HPX_CONSTEXPR char const* const get_component_base_name();

template <typename Component>
inline void set_component_type(component_type type)
HPX_CONSTEXPR inline void set_component_type(component_type type)
{
traits::component_type_database<Component>::set(type);
}

template <typename Component>
inline component_type get_component_type()
HPX_CONSTEXPR inline component_type get_component_type()
{
return traits::component_type_database<Component>::get();
}
Expand Down Expand Up @@ -253,13 +254,13 @@ namespace hpx { namespace components

#define HPX_DEFINE_COMPONENT_NAME_2(Component, name) \
namespace hpx { namespace components { \
template <> HPX_ALWAYS_EXPORT \
const char* get_component_name< Component, void>() \
template <> \
HPX_CONSTEXPR char const* const get_component_name< Component, void>() \
{ \
return HPX_PP_STRINGIZE(name); \
} \
template <> HPX_ALWAYS_EXPORT \
const char* get_component_base_name< Component, void>() \
template <> \
HPX_CONSTEXPR char const* const get_component_base_name< Component, void>() \
{ \
return nullptr; \
} \
Expand All @@ -268,13 +269,13 @@ namespace hpx { namespace components { \

#define HPX_DEFINE_COMPONENT_NAME_3(Component, name, base_name) \
namespace hpx { namespace components { \
template <> HPX_ALWAYS_EXPORT \
const char* get_component_name< Component, void>() \
template <> \
HPX_CONSTEXPR char const* const get_component_name< Component, void>() \
{ \
return HPX_PP_STRINGIZE(name); \
} \
template <> HPX_ALWAYS_EXPORT \
const char* get_component_base_name< Component, void>() \
template <> \
HPX_CONSTEXPR char const* const get_component_base_name< Component, void>() \
{ \
return base_name; \
} \
Expand Down
8 changes: 4 additions & 4 deletions hpx/runtime/components/server/component_base.hpp
Expand Up @@ -69,7 +69,7 @@ namespace hpx { namespace components

/// \brief finalize() will be called just before the instance gets
/// destructed
void finalize()
HPX_CONSTEXPR void finalize()
{
}

Expand All @@ -79,13 +79,13 @@ namespace hpx { namespace components
naming::gid_type const& gid) const;

// Pinning functionality
void pin()
HPX_CONSTEXPR void pin()
{
}
void unpin()
HPX_CONSTEXPR void unpin()
{
}
std::uint32_t pin_count() const
HPX_CONSTEXPR std::uint32_t pin_count() const
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion hpx/runtime/components/server/component_heap.hpp
Expand Up @@ -41,7 +41,7 @@ namespace hpx { namespace components { namespace detail { \
template <> HPX_ALWAYS_EXPORT \
Component::heap_type& component_heap_helper< Component>(...) \
{ \
util::reinitializable_static<Component::heap_type> heap; \
util::reinitializable_static< Component::heap_type> heap; \
return heap.get(); \
} \
}}} \
Expand Down

0 comments on commit 1e40175

Please sign in to comment.