Skip to content

Commit c087af7

Browse files
refactor: Remove hard-coded code in the memory barrier injection logic
1 parent 371bb52 commit c087af7

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/operations/invoker.cppm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,14 @@ constexpr auto make_div_zero(char const *reason)
365365
return make_error<CommonRep>(policy::error::kind::divide_by_zero, reason);
366366
}
367367

368-
constexpr auto apply_runtime_fence(bool enabled) noexcept -> void {
368+
constexpr auto apply_runtime_fence(bool enabled,
369+
std::memory_order order) noexcept -> void {
369370
if (!enabled) {
370371
return;
371372
}
372373

373374
if (!std::is_constant_evaluated()) {
374-
std::atomic_thread_fence(std::memory_order_seq_cst);
375+
std::atomic_thread_fence(order);
375376
}
376377
}
377378

@@ -660,12 +661,12 @@ constexpr auto run_value(CommonRep lhs, CommonRep rhs,
660661
op_binding_available<OpTag, ValuePolicy, CommonRep>,
661662
"Missing operation binding specialization for this OpTag/common type");
662663

663-
details::apply_runtime_fence(injection.fence_before);
664+
details::apply_runtime_fence(injection.fence_before, injection.order_before);
664665

665666
auto decision = op_binding<OpTag, ValuePolicy, CommonRep>::apply(lhs, rhs);
666667
auto finalized = ValueHandler::finalize(std::move(decision), injection);
667668

668-
details::apply_runtime_fence(injection.fence_after);
669+
details::apply_runtime_fence(injection.fence_after, injection.order_after);
669670
return finalized;
670671
}
671672

0 commit comments

Comments
 (0)