Skip to content

Commit

Permalink
Merge pull request #135 from elbeno/update-stdx-atomic
Browse files Browse the repository at this point in the history
🎨 Use `stdx::atomic`
  • Loading branch information
lukevalenty authored Oct 16, 2024
2 parents 4a1ce53 + 739f54a commit 5d61032
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ else()
cpmaddpackage("gh:intel/cicd-repo-infrastructure#3e2bef0")
endif()

add_versioned_package("gh:intel/cpp-std-extensions#67120f7")
add_versioned_package("gh:intel/cpp-baremetal-concurrency#659771e")
add_versioned_package("gh:intel/cpp-baremetal-concurrency#06e5901")
add_versioned_package("gh:intel/cpp-std-extensions#a36370b")
add_versioned_package("gh:boostorg/mp11#boost-1.83.0")

add_library(async INTERFACE)
Expand Down
1 change: 0 additions & 1 deletion include/async/schedulers/runloop_scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <stdx/concepts.hpp>
#include <stdx/intrusive_list.hpp>

#include <atomic>
#if HAS_CONDITION_VARIABLE
#include <condition_variable>
#include <mutex>
Expand Down
4 changes: 2 additions & 2 deletions include/async/schedulers/task_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#include <async/schedulers/task_manager_interface.hpp>
#include <conc/concurrency.hpp>

#include <stdx/atomic.hpp>
#include <stdx/function_traits.hpp>
#include <stdx/intrusive_forward_list.hpp>
#include <stdx/tuple.hpp>

#include <array>
#include <atomic>
#include <concepts>
#include <cstddef>
#include <memory>
Expand Down Expand Up @@ -40,7 +40,7 @@ struct priority_task_manager {
struct mutex;
std::array<stdx::intrusive_forward_list<task_t>, NumPriorities>
task_queues{};
std::atomic<int> task_count{};
stdx::atomic<int> task_count{};

public:
constexpr static auto create_task = async::create_task<task_t>;
Expand Down
4 changes: 2 additions & 2 deletions include/async/schedulers/timer_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include <async/schedulers/timer_manager_interface.hpp>
#include <conc/concurrency.hpp>

#include <stdx/atomic.hpp>
#include <stdx/function_traits.hpp>
#include <stdx/intrusive_list.hpp>
#include <stdx/tuple.hpp>

#include <algorithm>
#include <atomic>
#include <concepts>
#include <iterator>
#include <memory>
Expand Down Expand Up @@ -51,7 +51,7 @@ template <detail::timer_hal H> struct generic_timer_manager {
private:
struct mutex;
stdx::intrusive_list<task_t> task_queue{};
std::atomic<int> task_count{};
stdx::atomic<int> task_count{};

auto schedule(task_t *t) -> void {
if (std::empty(task_queue)) {
Expand Down
4 changes: 2 additions & 2 deletions include/async/schedulers/trigger_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include <async/schedulers/requeue_policy.hpp>
#include <conc/concurrency.hpp>

#include <stdx/atomic.hpp>
#include <stdx/ct_string.hpp>
#include <stdx/intrusive_list.hpp>
#include <stdx/type_traits.hpp>

#include <array>
#include <atomic>
#include <concepts>
#include <iterator>
#include <memory>
Expand Down Expand Up @@ -40,7 +40,7 @@ template <stdx::ct_string Name, typename... Args> struct trigger_manager {
private:
struct mutex;
std::array<stdx::intrusive_list<task_t>, 1> tasks{};
std::atomic<int> task_count{};
stdx::atomic<int> task_count{};

public:
auto enqueue(task_t &t) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions include/async/static_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#include <conc/concurrency.hpp>

#include <stdx/atomic.hpp>
#include <stdx/bit.hpp>
#include <stdx/bitset.hpp>
#include <stdx/compiler.hpp>

#include <array>
#include <atomic>
#include <cstddef>
#include <iterator>
#include <memory>
Expand Down Expand Up @@ -58,8 +58,8 @@ template <typename Name, typename T> struct static_allocator_t<Name, T, 1> {
constexpr static inline auto alignment = alignof(T);
constexpr static inline auto size = sizeof(T);

stdx::atomic<bool> used{};
alignas(alignment) std::array<std::byte, size> data{};
std::atomic<bool> used{};

template <typename... Args>
auto construct(Args &&...args) LIFETIMEBOUND -> T * {
Expand Down
4 changes: 2 additions & 2 deletions include/async/stop_token.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include <async/forwarding_query.hpp>
#include <conc/concurrency.hpp>

#include <stdx/atomic.hpp>
#include <stdx/ct_string.hpp>
#include <stdx/intrusive_list.hpp>

#include <atomic>
#include <concepts>
#include <type_traits>
#include <utility>
Expand Down Expand Up @@ -128,7 +128,7 @@ struct inplace_stop_source {
}

private:
std::atomic<bool> requested{};
stdx::atomic<bool> requested{};
stdx::intrusive_list<stop_callback_base> callbacks{};
};

Expand Down
8 changes: 4 additions & 4 deletions include/async/when_all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <async/env.hpp>
#include <async/stop_token.hpp>

#include <stdx/atomic.hpp>
#include <stdx/concepts.hpp>
#include <stdx/ct_string.hpp>
#include <stdx/tuple.hpp>
Expand All @@ -19,7 +20,6 @@
#include <boost/mp11/function.hpp>
#include <boost/mp11/list.hpp>

#include <atomic>
#include <concepts>
#include <cstddef>
#include <optional>
Expand Down Expand Up @@ -160,7 +160,7 @@ struct error_op_state<E, boost::mp11::mp_list<Sndrs...>> {
completion_signatures<set_error_t(typename error_t::value_type)>;

error_t e{};
std::atomic<bool> caught_error{};
stdx::atomic<bool> caught_error{};
};

template <typename E> struct is_error_sender {
Expand Down Expand Up @@ -265,7 +265,7 @@ struct op_state
stop_callback_for_t<stop_token_of_t<env_of_t<Rcvr>>, stop_callback_fn>;

[[no_unique_address]] Rcvr rcvr;
std::atomic<std::size_t> count{};
stdx::atomic<std::size_t> count{};
inplace_stop_source stop_source{};
std::optional<stop_callback_t> stop_cb{};
};
Expand Down Expand Up @@ -334,7 +334,7 @@ struct nostop_op_state
[[nodiscard]] auto get_stop_token() const -> never_stop_token { return {}; }

[[no_unique_address]] Rcvr rcvr;
std::atomic<std::size_t> count{};
stdx::atomic<std::size_t> count{};
};

template <stdx::ct_string Name, typename Rcvr, typename... Sndrs>
Expand Down
6 changes: 3 additions & 3 deletions include/async/when_any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
#include <async/type_traits.hpp>
#include <conc/concurrency.hpp>

#include <stdx/atomic.hpp>
#include <stdx/concepts.hpp>
#include <stdx/ct_string.hpp>
#include <stdx/functional.hpp>
#include <stdx/tuple.hpp>
#include <stdx/type_traits.hpp>
#include <stdx/utility.hpp>

#include <atomic>
#include <concepts>
#include <cstddef>
#include <optional>
Expand Down Expand Up @@ -293,7 +293,7 @@ struct op_state : sub_op_state<op_state<Name, StopPolicy, Rcvr, Sndrs...>, Rcvr,

[[no_unique_address]] Rcvr rcvr;
completions_t completions{};
std::atomic<std::size_t> count{};
stdx::atomic<std::size_t> count{};
inplace_stop_source stop_source{};
std::optional<stop_callback_t> stop_cb{};
};
Expand Down Expand Up @@ -369,7 +369,7 @@ struct nostop_op_state

[[no_unique_address]] Rcvr rcvr;
completions_t completions{};
std::atomic<std::size_t> count{};
stdx::atomic<std::size_t> count{};
[[no_unique_address]] never_stop_source stop_source{};
};

Expand Down

0 comments on commit 5d61032

Please sign in to comment.