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 cfe6adf commit ed1ac69
Show file tree
Hide file tree
Showing 52 changed files with 1,150 additions and 1,274 deletions.
4 changes: 2 additions & 2 deletions hpx/parallel/executors/thread_timed_execution.hpp
Expand Up @@ -8,11 +8,11 @@
#define HPX_PARALLEL_EXECUTORS_THREAD_TIMED_EXECUTION_JAN_09_2017_1117AM

#include <hpx/config.hpp>
#include <hpx/functional/deferred_call.hpp>
#include <hpx/execution/future.hpp>
#include <hpx/execution/traits/is_launch_policy.hpp>
#include <hpx/functional/deferred_call.hpp>
#include <hpx/local_lcos/packaged_task.hpp>
#include <hpx/timing/steady_clock.hpp>
#include <hpx/execution/traits/is_launch_policy.hpp>

#include <hpx/execution/executors/timed_execution.hpp>

Expand Down
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

0 comments on commit ed1ac69

Please sign in to comment.