Skip to content

Commit

Permalink
Merge pull request #3047 from STEllAR-GROUP/fix_tests
Browse files Browse the repository at this point in the history
Fixing #3044
  • Loading branch information
sithhell committed Dec 5, 2017
2 parents 2ec00bc + fdb97a9 commit f16b360
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
27 changes: 23 additions & 4 deletions hpx/lcos/detail/async_implementations.hpp
Expand Up @@ -12,6 +12,8 @@
#include <hpx/runtime/launch_policy.hpp>
#include <hpx/runtime/naming/address.hpp>
#include <hpx/runtime/naming/id_type.hpp>
#include <hpx/runtime/threads/thread.hpp>
#include <hpx/runtime/threads/thread_init_data.hpp>
#include <hpx/throw_exception.hpp>
#include <hpx/traits/action_was_object_migrated.hpp>
#include <hpx/traits/component_supports_migration.hpp>
Expand Down Expand Up @@ -151,6 +153,19 @@ namespace hpx { namespace detail
}
};

template <typename Action>
bool can_invoke_locally()
{
return !traits::action_decorate_function<Action>::value &&
this_thread::get_priority() ==
static_cast<threads::thread_priority>(
traits::action_priority<Action>::value) &&
this_thread::get_stack_size() ==
threads::get_stack_size(
static_cast<threads::thread_stacksize>(
traits::action_stacksize<Action>::value));
}

template <typename Action>
struct sync_local_invoke<Action, void>
{
Expand Down Expand Up @@ -209,7 +224,8 @@ namespace hpx { namespace detail
std::pair<bool, components::pinned_ptr> r;

naming::address addr;
if (agas::is_local_address_cached(id, addr))
if (agas::is_local_address_cached(id, addr) &&
can_invoke_locally<action_type>())
{
if (traits::component_supports_migration<component_type>::call())
{
Expand Down Expand Up @@ -272,7 +288,8 @@ namespace hpx { namespace detail
std::pair<bool, components::pinned_ptr> r;

naming::address addr;
if (agas::is_local_address_cached(id, addr))
if (agas::is_local_address_cached(id, addr) &&
can_invoke_locally<action_type>())
{
if (traits::component_supports_migration<component_type>::call())
{
Expand Down Expand Up @@ -335,7 +352,8 @@ namespace hpx { namespace detail
std::pair<bool, components::pinned_ptr> r;

naming::address addr;
if (agas::is_local_address_cached(id, addr))
if (agas::is_local_address_cached(id, addr) &&
can_invoke_locally<action_type>())
{
if (traits::component_supports_migration<component_type>::call())
{
Expand Down Expand Up @@ -452,7 +470,8 @@ namespace hpx { namespace detail
std::pair<bool, components::pinned_ptr> r;

naming::address addr;
if (agas::is_local_address_cached(id, addr))
if (agas::is_local_address_cached(id, addr) &&
can_invoke_locally<action_type>())
{
if (traits::component_supports_migration<component_type>::call())
{
Expand Down
1 change: 1 addition & 0 deletions hpx/runtime/actions/action_invoke_no_more_than.hpp
Expand Up @@ -64,6 +64,7 @@ namespace hpx { namespace actions { namespace detail
template <typename Action, int N>
struct action_decorate_function
{
static constexpr bool value = true;
// This wrapper is needed to stop infinite recursion when
// trying to get the possible additional function decoration
// from the component
Expand Down
2 changes: 2 additions & 0 deletions hpx/runtime/components/server/locking_hook.hpp
Expand Up @@ -46,6 +46,8 @@ namespace hpx { namespace components
: base_type(std::move(rhs))
{}

typedef void decorates_action;

/// This is the hook implementation for decorate_action which locks
/// the component ensuring that only one action is executed at a time
/// for this component instance.
Expand Down
2 changes: 2 additions & 0 deletions hpx/runtime/components/server/migration_support.hpp
Expand Up @@ -155,6 +155,8 @@ namespace hpx { namespace components
/// has been finished
void on_migrated() {}

typedef void decorates_action;

/// This is the hook implementation for decorate_action which makes
/// sure that the object becomes pinned during the execution of an
/// action.
Expand Down
4 changes: 4 additions & 0 deletions hpx/traits/action_decorate_function.hpp
Expand Up @@ -9,6 +9,7 @@
#include <hpx/runtime/naming_fwd.hpp>
#include <hpx/runtime/threads/thread_data_fwd.hpp>
#include <hpx/traits/detail/wrap_int.hpp>
#include <hpx/traits/has_xxx.hpp>
#include <hpx/util/unique_function.hpp>

#include <utility>
Expand Down Expand Up @@ -50,11 +51,14 @@ namespace hpx { namespace traits
return decorate_function_helper::template call<Action>(
0, lva, std::forward<F>(f));
}

HPX_HAS_XXX_TRAIT_DEF(decorates_action);
}

template <typename Action, typename Enable = void>
struct action_decorate_function
{
static constexpr bool value = detail::has_decorates_action<Action>::value;
template <typename F>
static threads::thread_function_type
call(naming::address_type lva, F && f)
Expand Down

0 comments on commit f16b360

Please sign in to comment.