Skip to content

Commit

Permalink
More cleaning up for module levels 19-20
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Aug 31, 2023
1 parent 8edd9b3 commit 39f2cdd
Show file tree
Hide file tree
Showing 34 changed files with 243 additions and 206 deletions.
12 changes: 10 additions & 2 deletions libs/core/futures/include/hpx/futures/detail/future_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,9 @@ namespace hpx::lcos::detail {
std::destroy_at(exception_ptr);
break;
}
default:
case empty:
[[fallthrough]];
case ready:
break;
}

Expand Down Expand Up @@ -1020,10 +1022,17 @@ namespace hpx::lcos::detail {
{
target.set_thread_id(threads::get_self_id());
}

~reset_id()
{
target_.set_thread_id(threads::invalid_thread_id);
}

reset_id(reset_id const&) = delete;
reset_id(reset_id&&) = delete;
reset_id& operator=(reset_id const&) = delete;
reset_id& operator=(reset_id&&) = delete;

cancelable_task_base& target_;
};

Expand All @@ -1046,7 +1055,6 @@ namespace hpx::lcos::detail {
hpx::intrusive_ptr<cancelable_task_base> this_(
this); // keep alive

std::unique_lock<mutex_type> l(mtx_);
hpx::detail::try_catch_exception_ptr(
[&]() {
if (!this->started_test_and_set())
Expand Down
39 changes: 25 additions & 14 deletions libs/core/futures/include/hpx/futures/future.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2022 Hartmut Kaiser
// Copyright (c) 2007-2023 Hartmut Kaiser
// Copyright (c) 2013 Agustin Berge
//
// SPDX-License-Identifier: BSL-1.0
Expand Down Expand Up @@ -169,12 +169,12 @@ namespace hpx::lcos::detail {
{
if (ar.is_preprocessing())
{
hpx::traits::detail::shared_state_ptr_for_t<Future> state =
auto shared_state =
hpx::traits::future_access<Future>::get_shared_state(f);

state->execute_deferred();
shared_state->execute_deferred();

preprocess_future(ar, *state);
preprocess_future(ar, *shared_state);
}
else
{
Expand Down Expand Up @@ -221,12 +221,12 @@ namespace hpx::lcos::detail {
{
if (ar.is_preprocessing())
{
hpx::traits::detail::shared_state_ptr_for_t<Future> state =
auto shared_state =
hpx::traits::future_access<Future>::get_shared_state(f);

state->execute_deferred();
shared_state->execute_deferred();

preprocess_future(ar, *state);
preprocess_future(ar, *shared_state);
}
else
{
Expand Down Expand Up @@ -323,9 +323,12 @@ namespace hpx::lcos::detail {
template <>
struct future_value<void> : future_data_result<void>
{
HPX_FORCEINLINE static void get(hpx::util::unused_type) noexcept {}
HPX_FORCEINLINE static constexpr void get(
hpx::util::unused_type) noexcept
{
}

static void get_default() noexcept {}
static constexpr void get_default() noexcept {}
};

///////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -477,6 +480,7 @@ namespace hpx::lcos::detail {

public:
future_base() noexcept = default;
~future_base() = default;

explicit future_base(hpx::intrusive_ptr<shared_state_type> const& p)
: shared_state_(p)
Expand Down Expand Up @@ -746,6 +750,11 @@ namespace hpx {
{
}

invalidate(invalidate const&) = delete;
invalidate(invalidate&&) = delete;
invalidate& operator=(invalidate const&) = delete;
invalidate& operator=(invalidate&&) = delete;

~invalidate()
{
f_.shared_state_.reset();
Expand Down Expand Up @@ -792,6 +801,8 @@ namespace hpx {
// - other.valid() == false.
future(future&& other) noexcept = default;

future(future const& other) noexcept = delete;

// Effects: constructs a future object by moving the instance referred
// to by rhs and unwrapping the inner future.
// Postconditions:
Expand Down Expand Up @@ -848,6 +859,8 @@ namespace hpx {
// - other.valid() == false.
future& operator=(future&& other) noexcept = default;

future& operator=(future const& other) noexcept = delete;

// Returns: shared_future<R>(HPX_MOVE(*this)).
// Postcondition: valid() == false.
shared_future<R> share() noexcept
Expand Down Expand Up @@ -877,9 +890,8 @@ namespace hpx {
invalidate on_exit(*this);

using result_type = typename shared_state_type::result_type;
result_type* result =
lcos::detail::future_get_result<result_type>::call(
this->shared_state_);
auto* result = lcos::detail::future_get_result<result_type>::call(
this->shared_state_);

// no error has been reported, return the result
return lcos::detail::future_value<R>::get(HPX_MOVE(*result));
Expand Down Expand Up @@ -1500,8 +1512,7 @@ namespace hpx {
{
return hpx::make_exceptional_future<T>(std::current_exception());
}

return future<T>();
return {};
}

///////////////////////////////////////////////////////////////////////////
Expand Down
11 changes: 2 additions & 9 deletions libs/core/futures/include/hpx/futures/futures_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace hpx::lcos::local {
task_object& operator=(task_object const&) = delete;
task_object& operator=(task_object&&) = delete;

~task_object() = default;
~task_object() override = default;

void do_run() noexcept override
{
Expand Down Expand Up @@ -230,7 +230,7 @@ namespace hpx::lcos::local {
task_object_allocator const&) = delete;
task_object_allocator& operator=(task_object_allocator&&) = delete;

~task_object_allocator() = default;
~task_object_allocator() override = default;

private:
void destroy() noexcept override
Expand Down Expand Up @@ -570,8 +570,6 @@ namespace hpx::lcos::local {
base_allocator>::template rebind_alloc<shared_state>;
using traits = std::allocator_traits<other_allocator>;

using init_no_addref = typename shared_state::init_no_addref;

using unique_ptr = std::unique_ptr<shared_state,
util::allocator_deleter<other_allocator>>;

Expand Down Expand Up @@ -673,8 +671,6 @@ namespace hpx::lcos::local {
base_allocator>::template rebind_alloc<shared_state>;
using traits = std::allocator_traits<other_allocator>;

using init_no_addref = typename shared_state::init_no_addref;

using unique_ptr = std::unique_ptr<shared_state,
util::allocator_deleter<other_allocator>>;

Expand Down Expand Up @@ -817,7 +813,6 @@ namespace hpx::lcos::local {
HPX_THROW_EXCEPTION(hpx::error::task_moved,
"futures_factory<Result()>::operator()",
"futures_factory invalid (has it been moved?)");
return;
}
task_->run();
}
Expand All @@ -840,7 +835,6 @@ namespace hpx::lcos::local {
HPX_THROW_EXCEPTION(hpx::error::task_moved,
"futures_factory<Result()>::post()",
"futures_factory invalid (has it been moved?)");
return threads::invalid_thread_id;
}
return task_->post(pool, annotation, HPX_MOVE(policy), ec);
}
Expand Down Expand Up @@ -882,7 +876,6 @@ namespace hpx::lcos::local {
HPX_THROW_EXCEPTION(hpx::error::task_moved,
"futures_factory<Result()>::set_exception",
"futures_factory invalid (has it been moved?)");
return;
}
task_->set_exception(e);
}
Expand Down
47 changes: 23 additions & 24 deletions libs/core/futures/include/hpx/futures/packaged_continuation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,17 @@ namespace hpx::lcos::detail {
if (threads::get_self_ptr() != nullptr)
target.set_id(threads::get_self_id());
}

reset_id(reset_id const&) = delete;
reset_id(reset_id&&) = delete;
reset_id& operator=(reset_id const&) = delete;
reset_id& operator=(reset_id&&) = delete;

~reset_id()
{
target_.set_id(threads::invalid_thread_id);
}

continuation& target_;
};

Expand All @@ -168,7 +175,7 @@ namespace hpx::lcos::detail {
typename Enable = std::enable_if_t<
!std::is_same_v<std::decay_t<Func>, continuation>>>
// NOLINTNEXTLINE(bugprone-forwarding-reference-overload)
continuation(Func&& f)
explicit continuation(Func&& f)
: started_(false)
, id_(threads::invalid_thread_id)
, f_(HPX_FORWARD(Func, f))
Expand All @@ -193,7 +200,6 @@ namespace hpx::lcos::detail {
HPX_THROW_EXCEPTION(hpx::error::task_already_started,
"continuation::ensure_started",
"this task has already been started");
return;
}
started_ = true;
}
Expand Down Expand Up @@ -380,17 +386,13 @@ namespace hpx::lcos::detail {
};
} // namespace hpx::lcos::detail

namespace hpx::traits::detail {

template <typename Future, typename F, typename ContResult,
typename Allocator>
struct shared_state_allocator<
lcos::detail::continuation<Future, F, ContResult>, Allocator>
{
using type = lcos::detail::continuation_allocator<Allocator, Future, F,
ContResult>;
};
} // namespace hpx::traits::detail
template <typename Future, typename F, typename ContResult, typename Allocator>
struct hpx::traits::detail::shared_state_allocator<
hpx::lcos::detail::continuation<Future, F, ContResult>, Allocator>
{
using type =
lcos::detail::continuation_allocator<Allocator, Future, F, ContResult>;
};

///////////////////////////////////////////////////////////////////////////////
namespace hpx::lcos::detail {
Expand Down Expand Up @@ -503,7 +505,7 @@ namespace hpx::lcos::detail {
public:
using init_no_addref = typename base_type::init_no_addref;

unwrap_continuation_allocator(other_allocator const& alloc)
explicit unwrap_continuation_allocator(other_allocator const& alloc)
: alloc_(alloc)
{
}
Expand All @@ -529,16 +531,13 @@ namespace hpx::lcos::detail {
};
} // namespace hpx::lcos::detail

namespace hpx::traits::detail {

template <typename ContResult, typename Allocator>
struct shared_state_allocator<lcos::detail::unwrap_continuation<ContResult>,
Allocator>
{
using type =
lcos::detail::unwrap_continuation_allocator<Allocator, ContResult>;
};
} // namespace hpx::traits::detail
template <typename ContResult, typename Allocator>
struct hpx::traits::detail::shared_state_allocator<
hpx::lcos::detail::unwrap_continuation<ContResult>, Allocator>
{
using type =
lcos::detail::unwrap_continuation_allocator<Allocator, ContResult>;
};

namespace hpx::lcos::detail {

Expand Down
4 changes: 2 additions & 2 deletions libs/core/futures/include/hpx/futures/packaged_task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ namespace hpx {
HPX_THROW_EXCEPTION(hpx::error::no_state,
"packaged_task<Signature>::operator()",
"this packaged_task has no valid shared state");
return;
}

// synchronous execution of the embedded function (object)
Expand Down Expand Up @@ -164,7 +163,8 @@ namespace std { //-V1061
};

template <typename Sig>
void swap(hpx::packaged_task<Sig>& lhs, hpx::packaged_task<Sig>& rhs)
void swap(
hpx::packaged_task<Sig>& lhs, hpx::packaged_task<Sig>& rhs) noexcept
{
lhs.swap(rhs);
}
Expand Down
Loading

0 comments on commit 39f2cdd

Please sign in to comment.