Skip to content

Commit

Permalink
Fixing is_timed_executor traits
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Sep 27, 2017
1 parent 8cbf0f6 commit cdfd59d
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 16 deletions.
4 changes: 3 additions & 1 deletion hpx/parallel/executors/v1/timed_executor_traits.hpp
Expand Up @@ -561,7 +561,9 @@ namespace hpx { namespace parallel { inline namespace v3
/// is_timed_executor is undefined.
///
template <typename T>
struct is_timed_executor; // defined in hpx/traits/is_timed_executor.hpp
struct is_timed_executor
: traits::is_timed_executor<T>
{};
}}}

#endif
Expand Down
1 change: 0 additions & 1 deletion hpx/traits/is_executor_parameters.hpp
Expand Up @@ -103,7 +103,6 @@ namespace hpx { namespace parallel { namespace execution
template <typename T>
constexpr bool is_executor_parameters_v = is_executor_parameters<T>::value;
#endif

}}}

namespace hpx { namespace traits
Expand Down
26 changes: 15 additions & 11 deletions hpx/traits/is_timed_executor.hpp
@@ -1,4 +1,4 @@
// Copyright (c) 2014-2015 Hartmut Kaiser
// Copyright (c) 2014-2017 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -7,12 +7,12 @@
#define HPX_TRAITS_IS_TIMED_EXECUTOR_AUG_05_2015_0840AM

#include <hpx/config.hpp>
#include <hpx/traits/v1/is_executor.hpp>
#include <hpx/traits/is_executor.hpp>
#include <hpx/util/decay.hpp>

#include <type_traits>

namespace hpx { namespace parallel { inline namespace v3
namespace hpx { namespace parallel { namespace execution
{
///////////////////////////////////////////////////////////////////////////
struct timed_executor_tag : executor_tag {};
Expand All @@ -22,31 +22,35 @@ namespace hpx { namespace parallel { inline namespace v3
/// \cond NOINTERNAL
template <typename T>
struct is_timed_executor
: std::is_base_of<timed_executor_tag, T>
{};

template <>
struct is_timed_executor<timed_executor_tag>
: std::false_type
{};
/// \endcond
}

// Executor type traits:

// Condition: T meets the syntactic requirements for OneWayExecutor
// Precondition: T is a complete type
template <typename T>
struct is_timed_executor
: detail::is_timed_executor<typename hpx::util::decay<T>::type>
{};

template <typename Executor, typename Enable = void>
struct timed_executor_traits;
template <typename T>
using is_timed_executor_t = typename is_timed_executor<T>::type;

#if defined(HPX_HAVE_CXX17_VARIABLE_TEMPLATES)
template <typename T>
constexpr bool is_timed_executor_v = is_timed_executor<T>::value;
#endif
}}}

namespace hpx { namespace traits
{
// new executor framework
template <typename Executor, typename Enable = void>
struct is_timed_executor
: parallel::v3::is_timed_executor<Executor>
: parallel::execution::is_timed_executor<Executor>
{};
}}

Expand Down
Expand Up @@ -119,7 +119,7 @@ void test_timed_executor()
}

///////////////////////////////////////////////////////////////////////////////
struct test_timed_async_executor2 : hpx::parallel::timed_executor_tag
struct test_timed_async_executor2
{
typedef hpx::parallel::parallel_execution_tag execution_category;

Expand Down Expand Up @@ -169,6 +169,24 @@ struct test_timed_async_executor3 : test_timed_async_executor1
}
};

namespace hpx { namespace traits
{
template <>
struct is_timed_executor<test_timed_async_executor1>
: std::true_type
{};

template <>
struct is_timed_executor<test_timed_async_executor2>
: std::true_type
{};

template <>
struct is_timed_executor<test_timed_async_executor3>
: std::true_type
{};
}}

///////////////////////////////////////////////////////////////////////////////
int hpx_main(int argc, char* argv[])
{
Expand Down
20 changes: 19 additions & 1 deletion tests/unit/parallel/executors/minimal_timed_sync_executor_v1.cpp
Expand Up @@ -119,7 +119,7 @@ void test_timed_executor()
}

///////////////////////////////////////////////////////////////////////////////
struct test_timed_async_executor2 : hpx::parallel::timed_executor_tag
struct test_timed_async_executor2
{
typedef hpx::parallel::sequential_execution_tag execution_category;

Expand Down Expand Up @@ -172,6 +172,24 @@ struct test_timed_async_executor3 : test_timed_async_executor1
}
};

namespace hpx { namespace traits
{
template <>
struct is_timed_executor<test_timed_async_executor1>
: std::true_type
{};

template <>
struct is_timed_executor<test_timed_async_executor2>
: std::true_type
{};

template <>
struct is_timed_executor<test_timed_async_executor3>
: std::true_type
{};
}}

///////////////////////////////////////////////////////////////////////////////
int hpx_main(int argc, char* argv[])
{
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/threads/resource_manager.cpp
Expand Up @@ -28,7 +28,7 @@ namespace test
dummy_parameters() = default;
};

static const dummy_parameters dummy;
static dummy_parameters HPX_CONSTEXPR_OR_CONST dummy{};
}

namespace hpx { namespace traits
Expand Down

0 comments on commit cdfd59d

Please sign in to comment.