Skip to content

Commit

Permalink
Clang-format the execution module
Browse files Browse the repository at this point in the history
  • Loading branch information
aurianer committed Dec 9, 2019
1 parent af7c370 commit e2945a1
Show file tree
Hide file tree
Showing 49 changed files with 1,079 additions and 1,196 deletions.
Expand Up @@ -18,8 +18,8 @@
#include <hpx/execution/traits/executor_traits.hpp>
#include <hpx/execution/traits/is_execution_policy.hpp>
#include <hpx/execution/traits/is_executor.hpp>
#include <hpx/serialization/serialize.hpp>
#include <hpx/execution/traits/is_launch_policy.hpp>
#include <hpx/serialization/serialize.hpp>

#include <type_traits>
#include <utility>
Expand Down
84 changes: 43 additions & 41 deletions libs/execution/include/hpx/execution/detail/future_await_traits.hpp
Expand Up @@ -11,8 +11,8 @@

#include <hpx/config.hpp>
#include <hpx/execution/detail/future_data.hpp>
#include <hpx/memory/intrusive_ptr.hpp>
#include <hpx/execution/traits/future_access.hpp>
#include <hpx/memory/intrusive_ptr.hpp>

#if defined(HPX_HAVE_EMULATE_COROUTINE_SUPPORT_LIBRARY)
#include <hpx/util/await_traits.hpp>
Expand All @@ -25,17 +25,22 @@
#include <utility>

///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace lcos { namespace detail
{
namespace hpx { namespace lcos { namespace detail {
///////////////////////////////////////////////////////////////////////////
// this was removed from the TS, so we define our own
struct suspend_if
{
bool is_ready_;

explicit suspend_if(bool cond) noexcept : is_ready_(!cond) {}
explicit suspend_if(bool cond) noexcept
: is_ready_(!cond)
{
}

bool await_ready() noexcept { return is_ready_; }
bool await_ready() noexcept
{
return is_ready_;
}
void await_suspend(std::experimental::coroutine_handle<>) noexcept {}
void await_resume() noexcept {}
};
Expand All @@ -50,18 +55,16 @@ namespace hpx { namespace lcos { namespace detail
}

template <typename T, typename Promise>
HPX_FORCEINLINE void await_suspend(future<T>& f,
std::experimental::coroutine_handle<Promise> rh)
HPX_FORCEINLINE void await_suspend(
future<T>& f, std::experimental::coroutine_handle<Promise> rh)
{
// f.then([=](future<T> result) {});
auto st = traits::detail::get_shared_state(f);
st->set_on_completed(
[=]() mutable
{
if (st->has_exception())
rh.promise().set_exception(st->get_exception_ptr());
rh();
});
st->set_on_completed([=]() mutable {
if (st->has_exception())
rh.promise().set_exception(st->get_exception_ptr());
rh();
});
}

template <typename T>
Expand All @@ -72,13 +75,13 @@ namespace hpx { namespace lcos { namespace detail

// Allow wrapped futures to be unwrapped, if possible.
template <typename T>
HPX_FORCEINLINE T await_resume(future<future<T> >& f)
HPX_FORCEINLINE T await_resume(future<future<T>>& f)
{
return f.get().get();
}

template <typename T>
HPX_FORCEINLINE T await_resume(future<shared_future<T> >& f)
HPX_FORCEINLINE T await_resume(future<shared_future<T>>& f)
{
return f.get().get();
}
Expand All @@ -92,18 +95,16 @@ namespace hpx { namespace lcos { namespace detail
}

template <typename T, typename Promise>
HPX_FORCEINLINE void await_suspend(shared_future<T>& f,
std::experimental::coroutine_handle<Promise> rh)
HPX_FORCEINLINE void await_suspend(
shared_future<T>& f, std::experimental::coroutine_handle<Promise> rh)
{
// f.then([=](shared_future<T> result) {})
auto st = traits::detail::get_shared_state(f);
st->set_on_completed(
[=]() mutable
{
if (st->has_exception())
rh.promise().set_exception(st->get_exception_ptr());
rh();
});
st->set_on_completed([=]() mutable {
if (st->has_exception())
rh.promise().set_exception(st->get_exception_ptr());
rh();
});
}

template <typename T>
Expand All @@ -129,8 +130,8 @@ namespace hpx { namespace lcos { namespace detail
hpx::lcos::future<T> get_return_object()
{
hpx::intrusive_ptr<base_type> shared_state(this);
return hpx::traits::future_access<hpx::lcos::future<T> >::
create(std::move(shared_state));
return hpx::traits::future_access<hpx::lcos::future<T>>::create(
std::move(shared_state));
}

std::experimental::suspend_never initial_suspend()
Expand All @@ -148,27 +149,29 @@ namespace hpx { namespace lcos { namespace detail

void set_exception(std::exception_ptr e)
{
try {
try
{
std::rethrow_exception(std::move(e));
}
catch (...) {
catch (...)
{
this->base_type::set_exception(std::current_exception());
}
}

void destroy()
{
std::experimental::coroutine_handle<Derived>::
from_promise(*static_cast<Derived*>(this)).destroy();
std::experimental::coroutine_handle<Derived>::from_promise(
*static_cast<Derived*>(this))
.destroy();
}
};
}}}
}}} // namespace hpx::lcos::detail

///////////////////////////////////////////////////////////////////////////////
namespace std { namespace experimental
{
namespace std { namespace experimental {
// Allow for functions which use co_await to return an hpx::future<T>
template <typename T, typename ...Ts>
template <typename T, typename... Ts>
struct coroutine_traits<hpx::lcos::future<T>, Ts...>
{
struct promise_type
Expand All @@ -178,14 +181,14 @@ namespace std { namespace experimental
hpx::lcos::detail::coroutine_promise_base<T, promise_type>;

template <typename U>
void return_value(U && value)
void return_value(U&& value)
{
this->base_type::set_value(std::forward<U>(value));
}
};
};

template <typename ...Ts>
template <typename... Ts>
struct coroutine_traits<hpx::lcos::future<void>, Ts...>
{
struct promise_type
Expand All @@ -200,8 +203,7 @@ namespace std { namespace experimental
}
};
};
}}

#endif // HPX_HAVE_AWAIT
#endif // HPX_LCOS_ACBA3E3F_7B29_41D1_AE85_C73CB69D089C
}} // namespace std::experimental

#endif // HPX_HAVE_AWAIT
#endif // HPX_LCOS_ACBA3E3F_7B29_41D1_AE85_C73CB69D089C
14 changes: 6 additions & 8 deletions libs/execution/include/hpx/execution/detail/future_data.hpp
Expand Up @@ -11,18 +11,18 @@
#include <hpx/assertion.hpp>
#include <hpx/coroutines/detail/get_stack_pointer.hpp>
#include <hpx/errors.hpp>
#include <hpx/execution/launch_policy.hpp>
#include <hpx/execution/traits/future_access.hpp>
#include <hpx/functional/bind.hpp>
#include <hpx/functional/unique_function.hpp>
#include <hpx/synchronization/condition_variable.hpp>
#include <hpx/synchronization/spinlock.hpp>
#include <hpx/memory/intrusive_ptr.hpp>
#include <hpx/execution/launch_policy.hpp>
#include <hpx/runtime/threads/thread_executor.hpp>
#include <hpx/runtime/threads/thread_helpers.hpp>
#include <hpx/synchronization/condition_variable.hpp>
#include <hpx/synchronization/spinlock.hpp>
#include <hpx/thread_support/assert_owns_lock.hpp>
#include <hpx/thread_support/atomic_count.hpp>
#include <hpx/timing/steady_clock.hpp>
#include <hpx/execution/traits/future_access.hpp>
#include <hpx/traits/get_remote_result.hpp>
#include <hpx/type_support/decay.hpp>
#include <hpx/type_support/unused.hpp>
Expand Down Expand Up @@ -864,10 +864,8 @@ namespace hpx { namespace lcos { namespace detail {

// run in a separate thread
virtual threads::thread_id_type apply(
threads::thread_pool_base* /*pool*/,
const char* /*annotation*/,
launch /*policy*/,
threads::thread_priority /*priority*/,
threads::thread_pool_base* /*pool*/, const char* /*annotation*/,
launch /*policy*/, threads::thread_priority /*priority*/,
threads::thread_stacksize /*stacksize*/,
threads::thread_schedule_hint /*schedulehint*/, error_code& /*ec*/)
{
Expand Down
17 changes: 7 additions & 10 deletions libs/execution/include/hpx/execution/detail/future_traits.hpp
Expand Up @@ -9,30 +9,27 @@
#define HPX_LCOS_DETAIL_FUTURE_TRAITS_DEC_05_2017_0214PM

#include <hpx/config.hpp>
#include <hpx/type_support/always_void.hpp>
#include <hpx/execution/traits/future_traits.hpp>
#include <hpx/type_support/always_void.hpp>

#include <iterator>

namespace hpx { namespace lcos { namespace detail
{
namespace hpx { namespace lcos { namespace detail {
///////////////////////////////////////////////////////////////////////////
template <typename Iter, typename Enable = void>
struct future_iterator_traits
{};
{
};

template <typename Iterator>
struct future_iterator_traits<Iterator,
typename hpx::util::always_void<
typename std::iterator_traits<Iterator>::value_type
>::type>
typename std::iterator_traits<Iterator>::value_type>::type>
{
typedef
typename std::iterator_traits<Iterator>::value_type
type;
typedef typename std::iterator_traits<Iterator>::value_type type;

typedef hpx::traits::future_traits<type> traits_type;
};
}}}
}}} // namespace hpx::lcos::detail

#endif
2 changes: 1 addition & 1 deletion libs/execution/include/hpx/execution/exception_list.hpp
Expand Up @@ -11,8 +11,8 @@
#include <hpx/config.hpp>
#include <hpx/assertion.hpp>
#include <hpx/errors.hpp>
#include <hpx/hpx_finalize.hpp>
#include <hpx/execution/future.hpp>
#include <hpx/hpx_finalize.hpp>
#include <hpx/type_support/decay.hpp>

#include <hpx/execution/execution_policy_fwd.hpp>
Expand Down
2 changes: 1 addition & 1 deletion libs/execution/include/hpx/execution/execution_policy.hpp
Expand Up @@ -22,8 +22,8 @@
#include <hpx/execution/traits/is_execution_policy.hpp>
#include <hpx/execution/traits/is_executor.hpp>
#include <hpx/execution/traits/is_executor_parameters.hpp>
#include <hpx/serialization/serialize.hpp>
#include <hpx/execution/traits/is_launch_policy.hpp>
#include <hpx/serialization/serialize.hpp>
#include <hpx/type_support/decay.hpp>

#include <memory>
Expand Down
Expand Up @@ -12,9 +12,9 @@

#include <hpx/config.hpp>
#include <hpx/datastructures/detail/pack.hpp>
#include <hpx/execution/future.hpp>
#include <hpx/functional/result_of.hpp>
#include <hpx/functional/traits/is_action.hpp>
#include <hpx/execution/future.hpp>
#include <hpx/runtime/components/server/invoke_function.hpp>
#include <hpx/traits/is_distribution_policy.hpp>
#include <hpx/type_support/decay.hpp>
Expand Down
17 changes: 9 additions & 8 deletions libs/execution/include/hpx/execution/executors/execution.hpp
Expand Up @@ -18,18 +18,18 @@
#include <hpx/datastructures/detail/pack.hpp>
#include <hpx/datastructures/tuple.hpp>
#include <hpx/errors.hpp>
#include <hpx/functional/bind_back.hpp>
#include <hpx/functional/invoke.hpp>
#include <hpx/iterator_support/range.hpp>
#include <hpx/execution/executors/fused_bulk_execute.hpp>
#include <hpx/execution/traits/executor_traits.hpp>
#include <hpx/execution/traits/is_executor.hpp>
#include <hpx/functional/deferred_call.hpp>
#include <hpx/execution/future.hpp>
#include <hpx/lcos/wait_all.hpp>
#include <hpx/execution/traits/executor_traits.hpp>
#include <hpx/execution/traits/future_access.hpp>
#include <hpx/execution/traits/future_then_result.hpp>
#include <hpx/execution/traits/future_traits.hpp>
#include <hpx/execution/traits/is_executor.hpp>
#include <hpx/functional/bind_back.hpp>
#include <hpx/functional/deferred_call.hpp>
#include <hpx/functional/invoke.hpp>
#include <hpx/iterator_support/range.hpp>
#include <hpx/lcos/wait_all.hpp>
#include <hpx/type_support/detail/wrap_int.hpp>
#include <hpx/util/unwrap.hpp>

Expand Down Expand Up @@ -1142,7 +1142,8 @@ namespace hpx { namespace parallel { namespace execution {
-> result_future_type {
// use unwrap directly (instead of lazily) to avoid
// having to pull in dataflow
return hpx::util::unwrap(func(std::move(predecessor)));
return hpx::util::unwrap(
func(std::move(predecessor)));
});

return hpx::traits::future_access<result_future_type>::create(
Expand Down
Expand Up @@ -14,13 +14,13 @@
#include <hpx/config.hpp>
#include <hpx/concepts/has_member_xxx.hpp>
#include <hpx/datastructures/detail/pack.hpp>
#include <hpx/execution/future.hpp>
#include <hpx/execution/traits/is_executor.hpp>
#include <hpx/execution/traits/is_executor_parameters.hpp>
#include <hpx/execution/future.hpp>
#include <hpx/execution/traits/is_launch_policy.hpp>
#include <hpx/preprocessor/cat.hpp>
#include <hpx/preprocessor/stringize.hpp>
#include <hpx/serialization/base_object.hpp>
#include <hpx/execution/traits/is_launch_policy.hpp>
#include <hpx/type_support/decay.hpp>
#include <hpx/type_support/detail/wrap_int.hpp>

Expand Down
Expand Up @@ -18,22 +18,22 @@
#include <hpx/execution/executors/fused_bulk_execute.hpp>
#include <hpx/execution/executors/post_policy_dispatch.hpp>
#include <hpx/execution/executors/static_chunk_size.hpp>
#include <hpx/execution/future.hpp>
#include <hpx/execution/launch_policy.hpp>
#include <hpx/execution/traits/future_traits.hpp>
#include <hpx/execution/traits/is_executor.hpp>
#include <hpx/functional/bind_back.hpp>
#include <hpx/functional/deferred_call.hpp>
#include <hpx/functional/invoke.hpp>
#include <hpx/functional/one_shot.hpp>
#include <hpx/iterator_support/range.hpp>
#include <hpx/execution/future.hpp>
#include <hpx/execution/launch_policy.hpp>
#include <hpx/runtime/threads/policies/scheduler_base.hpp>
#include <hpx/runtime/threads/thread_data.hpp>
#include <hpx/runtime/threads/thread_data_fwd.hpp>
#include <hpx/runtime/threads/thread_helpers.hpp>
#include <hpx/runtime/threads/thread_pool_base.hpp>
#include <hpx/serialization/serialize.hpp>
#include <hpx/synchronization/latch.hpp>
#include <hpx/execution/traits/future_traits.hpp>
#include <hpx/util/unwrap.hpp>

#include <algorithm>
Expand Down
Expand Up @@ -16,16 +16,16 @@
#include <hpx/execution/algorithms/detail/predicates.hpp>
#include <hpx/execution/executors/post_policy_dispatch.hpp>
#include <hpx/execution/executors/static_chunk_size.hpp>
#include <hpx/execution/future.hpp>
#include <hpx/execution/launch_policy.hpp>
#include <hpx/execution/traits/future_traits.hpp>
#include <hpx/execution/traits/is_executor.hpp>
#include <hpx/functional/invoke.hpp>
#include <hpx/iterator_support/range.hpp>
#include <hpx/execution/future.hpp>
#include <hpx/runtime/get_worker_thread_num.hpp>
#include <hpx/execution/launch_policy.hpp>
#include <hpx/runtime/threads/thread_helpers.hpp>
#include <hpx/serialization/serialize.hpp>
#include <hpx/synchronization/latch.hpp>
#include <hpx/execution/traits/future_traits.hpp>

#include <algorithm>
#include <cstddef>
Expand Down

0 comments on commit e2945a1

Please sign in to comment.