Skip to content

Commit a0c6d49

Browse files
StellarBothkaiser
andcommitted
Merge #6336
6336: More cleaning up for module levels 19-20 r=hkaiser a=hkaiser Co-authored-by: Hartmut Kaiser <[email protected]>
2 parents c84b21b + 7142a49 commit a0c6d49

34 files changed

+243
-207
lines changed

libs/core/futures/include/hpx/futures/detail/future_data.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,9 @@ namespace hpx::lcos::detail {
656656
std::destroy_at(exception_ptr);
657657
break;
658658
}
659-
default:
659+
case empty:
660+
[[fallthrough]];
661+
case ready:
660662
break;
661663
}
662664

@@ -1020,10 +1022,17 @@ namespace hpx::lcos::detail {
10201022
{
10211023
target.set_thread_id(threads::get_self_id());
10221024
}
1025+
10231026
~reset_id()
10241027
{
10251028
target_.set_thread_id(threads::invalid_thread_id);
10261029
}
1030+
1031+
reset_id(reset_id const&) = delete;
1032+
reset_id(reset_id&&) = delete;
1033+
reset_id& operator=(reset_id const&) = delete;
1034+
reset_id& operator=(reset_id&&) = delete;
1035+
10271036
cancelable_task_base& target_;
10281037
};
10291038

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

1049-
std::unique_lock<mutex_type> l(mtx_);
10501058
hpx::detail::try_catch_exception_ptr(
10511059
[&]() {
10521060
if (!this->started_test_and_set())

libs/core/futures/include/hpx/futures/future.hpp

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2007-2022 Hartmut Kaiser
1+
// Copyright (c) 2007-2023 Hartmut Kaiser
22
// Copyright (c) 2013 Agustin Berge
33
//
44
// SPDX-License-Identifier: BSL-1.0
@@ -169,12 +169,12 @@ namespace hpx::lcos::detail {
169169
{
170170
if (ar.is_preprocessing())
171171
{
172-
hpx::traits::detail::shared_state_ptr_for_t<Future> state =
172+
auto shared_state =
173173
hpx::traits::future_access<Future>::get_shared_state(f);
174174

175-
state->execute_deferred();
175+
shared_state->execute_deferred();
176176

177-
preprocess_future(ar, *state);
177+
preprocess_future(ar, *shared_state);
178178
}
179179
else
180180
{
@@ -221,12 +221,12 @@ namespace hpx::lcos::detail {
221221
{
222222
if (ar.is_preprocessing())
223223
{
224-
hpx::traits::detail::shared_state_ptr_for_t<Future> state =
224+
auto shared_state =
225225
hpx::traits::future_access<Future>::get_shared_state(f);
226226

227-
state->execute_deferred();
227+
shared_state->execute_deferred();
228228

229-
preprocess_future(ar, *state);
229+
preprocess_future(ar, *shared_state);
230230
}
231231
else
232232
{
@@ -323,9 +323,12 @@ namespace hpx::lcos::detail {
323323
template <>
324324
struct future_value<void> : future_data_result<void>
325325
{
326-
HPX_FORCEINLINE static void get(hpx::util::unused_type) noexcept {}
326+
HPX_FORCEINLINE static constexpr void get(
327+
hpx::util::unused_type) noexcept
328+
{
329+
}
327330

328-
static void get_default() noexcept {}
331+
static constexpr void get_default() noexcept {}
329332
};
330333

331334
///////////////////////////////////////////////////////////////////////////
@@ -477,6 +480,7 @@ namespace hpx::lcos::detail {
477480

478481
public:
479482
future_base() noexcept = default;
483+
~future_base() = default;
480484

481485
explicit future_base(hpx::intrusive_ptr<shared_state_type> const& p)
482486
: shared_state_(p)
@@ -746,6 +750,11 @@ namespace hpx {
746750
{
747751
}
748752

753+
invalidate(invalidate const&) = delete;
754+
invalidate(invalidate&&) = delete;
755+
invalidate& operator=(invalidate const&) = delete;
756+
invalidate& operator=(invalidate&&) = delete;
757+
749758
~invalidate()
750759
{
751760
f_.shared_state_.reset();
@@ -792,6 +801,8 @@ namespace hpx {
792801
// - other.valid() == false.
793802
future(future&& other) noexcept = default;
794803

804+
future(future const& other) noexcept = delete;
805+
795806
// Effects: constructs a future object by moving the instance referred
796807
// to by rhs and unwrapping the inner future.
797808
// Postconditions:
@@ -848,6 +859,8 @@ namespace hpx {
848859
// - other.valid() == false.
849860
future& operator=(future&& other) noexcept = default;
850861

862+
future& operator=(future const& other) noexcept = delete;
863+
851864
// Returns: shared_future<R>(HPX_MOVE(*this)).
852865
// Postcondition: valid() == false.
853866
shared_future<R> share() noexcept
@@ -877,9 +890,8 @@ namespace hpx {
877890
invalidate on_exit(*this);
878891

879892
using result_type = typename shared_state_type::result_type;
880-
result_type* result =
881-
lcos::detail::future_get_result<result_type>::call(
882-
this->shared_state_);
893+
auto* result = lcos::detail::future_get_result<result_type>::call(
894+
this->shared_state_);
883895

884896
// no error has been reported, return the result
885897
return lcos::detail::future_value<R>::get(HPX_MOVE(*result));
@@ -1500,8 +1512,7 @@ namespace hpx {
15001512
{
15011513
return hpx::make_exceptional_future<T>(std::current_exception());
15021514
}
1503-
1504-
return future<T>();
1515+
return {};
15051516
}
15061517

15071518
///////////////////////////////////////////////////////////////////////////

libs/core/futures/include/hpx/futures/futures_factory.hpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ namespace hpx::lcos::local {
7878
task_object& operator=(task_object const&) = delete;
7979
task_object& operator=(task_object&&) = delete;
8080

81-
~task_object() = default;
81+
~task_object() override = default;
8282

8383
void do_run() noexcept override
8484
{
@@ -230,7 +230,7 @@ namespace hpx::lcos::local {
230230
task_object_allocator const&) = delete;
231231
task_object_allocator& operator=(task_object_allocator&&) = delete;
232232

233-
~task_object_allocator() = default;
233+
~task_object_allocator() override = default;
234234

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

573-
using init_no_addref = typename shared_state::init_no_addref;
574-
575573
using unique_ptr = std::unique_ptr<shared_state,
576574
util::allocator_deleter<other_allocator>>;
577575

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

676-
using init_no_addref = typename shared_state::init_no_addref;
677-
678674
using unique_ptr = std::unique_ptr<shared_state,
679675
util::allocator_deleter<other_allocator>>;
680676

@@ -817,7 +813,6 @@ namespace hpx::lcos::local {
817813
HPX_THROW_EXCEPTION(hpx::error::task_moved,
818814
"futures_factory<Result()>::operator()",
819815
"futures_factory invalid (has it been moved?)");
820-
return;
821816
}
822817
task_->run();
823818
}
@@ -840,7 +835,6 @@ namespace hpx::lcos::local {
840835
HPX_THROW_EXCEPTION(hpx::error::task_moved,
841836
"futures_factory<Result()>::post()",
842837
"futures_factory invalid (has it been moved?)");
843-
return threads::invalid_thread_id;
844838
}
845839
return task_->post(pool, annotation, HPX_MOVE(policy), ec);
846840
}
@@ -882,7 +876,6 @@ namespace hpx::lcos::local {
882876
HPX_THROW_EXCEPTION(hpx::error::task_moved,
883877
"futures_factory<Result()>::set_exception",
884878
"futures_factory invalid (has it been moved?)");
885-
return;
886879
}
887880
task_->set_exception(e);
888881
}

libs/core/futures/include/hpx/futures/packaged_continuation.hpp

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,17 @@ namespace hpx::lcos::detail {
154154
if (threads::get_self_ptr() != nullptr)
155155
target.set_id(threads::get_self_id());
156156
}
157+
158+
reset_id(reset_id const&) = delete;
159+
reset_id(reset_id&&) = delete;
160+
reset_id& operator=(reset_id const&) = delete;
161+
reset_id& operator=(reset_id&&) = delete;
162+
157163
~reset_id()
158164
{
159165
target_.set_id(threads::invalid_thread_id);
160166
}
167+
161168
continuation& target_;
162169
};
163170

@@ -168,7 +175,7 @@ namespace hpx::lcos::detail {
168175
typename Enable = std::enable_if_t<
169176
!std::is_same_v<std::decay_t<Func>, continuation>>>
170177
// NOLINTNEXTLINE(bugprone-forwarding-reference-overload)
171-
continuation(Func&& f)
178+
explicit continuation(Func&& f)
172179
: started_(false)
173180
, id_(threads::invalid_thread_id)
174181
, f_(HPX_FORWARD(Func, f))
@@ -193,7 +200,6 @@ namespace hpx::lcos::detail {
193200
HPX_THROW_EXCEPTION(hpx::error::task_already_started,
194201
"continuation::ensure_started",
195202
"this task has already been started");
196-
return;
197203
}
198204
started_ = true;
199205
}
@@ -380,17 +386,13 @@ namespace hpx::lcos::detail {
380386
};
381387
} // namespace hpx::lcos::detail
382388

383-
namespace hpx::traits::detail {
384-
385-
template <typename Future, typename F, typename ContResult,
386-
typename Allocator>
387-
struct shared_state_allocator<
388-
lcos::detail::continuation<Future, F, ContResult>, Allocator>
389-
{
390-
using type = lcos::detail::continuation_allocator<Allocator, Future, F,
391-
ContResult>;
392-
};
393-
} // namespace hpx::traits::detail
389+
template <typename Future, typename F, typename ContResult, typename Allocator>
390+
struct hpx::traits::detail::shared_state_allocator<
391+
hpx::lcos::detail::continuation<Future, F, ContResult>, Allocator>
392+
{
393+
using type =
394+
lcos::detail::continuation_allocator<Allocator, Future, F, ContResult>;
395+
};
394396

395397
///////////////////////////////////////////////////////////////////////////////
396398
namespace hpx::lcos::detail {
@@ -503,7 +505,7 @@ namespace hpx::lcos::detail {
503505
public:
504506
using init_no_addref = typename base_type::init_no_addref;
505507

506-
unwrap_continuation_allocator(other_allocator const& alloc)
508+
explicit unwrap_continuation_allocator(other_allocator const& alloc)
507509
: alloc_(alloc)
508510
{
509511
}
@@ -529,16 +531,13 @@ namespace hpx::lcos::detail {
529531
};
530532
} // namespace hpx::lcos::detail
531533

532-
namespace hpx::traits::detail {
533-
534-
template <typename ContResult, typename Allocator>
535-
struct shared_state_allocator<lcos::detail::unwrap_continuation<ContResult>,
536-
Allocator>
537-
{
538-
using type =
539-
lcos::detail::unwrap_continuation_allocator<Allocator, ContResult>;
540-
};
541-
} // namespace hpx::traits::detail
534+
template <typename ContResult, typename Allocator>
535+
struct hpx::traits::detail::shared_state_allocator<
536+
hpx::lcos::detail::unwrap_continuation<ContResult>, Allocator>
537+
{
538+
using type =
539+
lcos::detail::unwrap_continuation_allocator<Allocator, ContResult>;
540+
};
542541

543542
namespace hpx::lcos::detail {
544543

libs/core/futures/include/hpx/futures/packaged_task.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ namespace hpx {
8383
HPX_THROW_EXCEPTION(hpx::error::no_state,
8484
"packaged_task<Signature>::operator()",
8585
"this packaged_task has no valid shared state");
86-
return;
8786
}
8887

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

166165
template <typename Sig>
167-
void swap(hpx::packaged_task<Sig>& lhs, hpx::packaged_task<Sig>& rhs)
166+
void swap(
167+
hpx::packaged_task<Sig>& lhs, hpx::packaged_task<Sig>& rhs) noexcept
168168
{
169169
lhs.swap(rhs);
170170
}

0 commit comments

Comments
 (0)