21 static_assert(Capacity >= 2 && (Capacity & (Capacity - 1)) == 0,
22 "probe capacity must be a power of two");
26 attached_.store(
true, std::memory_order_release);
29 attached_.store(
false, std::memory_order_release);
32 return attached_.load(std::memory_order_acquire);
38 const auto write = write_.load(std::memory_order_relaxed);
39 const auto read = read_.load(std::memory_order_acquire);
40 if (write - read == Capacity) {
41 dropped_.fetch_add(1, std::memory_order_relaxed);
44 sample.sequence = write;
45 slots_[write & (Capacity - 1)] = sample;
46 write_.store(write + 1, std::memory_order_release);
51 const auto read = read_.load(std::memory_order_relaxed);
52 if (read == write_.load(std::memory_order_acquire))
54 sample = slots_[read & (Capacity - 1)];
55 read_.store(read + 1, std::memory_order_release);
60 return dropped_.load(std::memory_order_relaxed);
64 alignas(64) std::atomic<std::uint64_t> write_{0};
65 alignas(64) std::atomic<std::uint64_t> read_{0};
66 std::atomic<std::uint64_t> dropped_{0};
67 std::atomic<bool> attached_{
false};
68 GraphRuntimeProbeSample slots_[Capacity]{};
Definition graph_runtime_probe.hpp:20
bool try_pop(GraphRuntimeProbeSample &sample) noexcept
Definition graph_runtime_probe.hpp:50
std::uint64_t dropped() const noexcept
Definition graph_runtime_probe.hpp:59
void attach() noexcept
Definition graph_runtime_probe.hpp:25
bool try_push(GraphRuntimeProbeSample sample) noexcept
Definition graph_runtime_probe.hpp:35
void detach() noexcept
Definition graph_runtime_probe.hpp:28
bool attached() const noexcept
Definition graph_runtime_probe.hpp:31
Definition graph_runtime_buffer_assignment.hpp:8
Definition graph_runtime_probe.hpp:9
std::uint64_t sequence
Definition graph_runtime_probe.hpp:10
float peak
Definition graph_runtime_probe.hpp:14
float rms
Definition graph_runtime_probe.hpp:15
std::uint32_t frames
Definition graph_runtime_probe.hpp:13
std::uint32_t edge_index
Definition graph_runtime_probe.hpp:12
std::uint64_t timestamp_samples
Definition graph_runtime_probe.hpp:11