From c4a44db26c6aa63b5402d1fe3b2b588df50e5082 Mon Sep 17 00:00:00 2001 From: rstein Date: Wed, 11 Oct 2023 13:29:36 +0200 Subject: [PATCH] renamed Buffer, CircularBuffer, Profiler and related files and structs --- .../include/gnuradio-4.0/basic/data_sink.hpp | 22 +-- blocks/basic/test/qa_data_sink.cpp | 2 +- .../filter/time_domain_filter.hpp | 28 +-- .../include/gnuradio-4.0/fourier/fft.hpp | 2 +- core/benchmarks/CMakeLists.txt | 8 +- .../{bm_buffer.cpp => bm_Buffer.cpp} | 10 +- ...istory_buffer.cpp => bm_HistoryBuffer.cpp} | 36 ++-- .../{bm_profiler.cpp => bm_Profiler.cpp} | 16 +- .../{bm_scheduler.cpp => bm_Scheduler.cpp} | 4 +- core/include/gnuradio-4.0/Block.hpp | 2 +- .../gnuradio-4.0/{buffer.hpp => Buffer.hpp} | 0 ...buffer_skeleton.hpp => BufferSkeleton.hpp} | 30 ++-- ...circular_buffer.hpp => CircularBuffer.hpp} | 32 ++-- .../{claim_strategy.hpp => ClaimStrategy.hpp} | 10 +- core/include/gnuradio-4.0/Graph.hpp | 8 +- .../{history_buffer.hpp => HistoryBuffer.hpp} | 12 +- core/include/gnuradio-4.0/Port.hpp | 6 +- .../{profiler.hpp => Profiler.hpp} | 160 +++++++++--------- core/include/gnuradio-4.0/Scheduler.hpp | 58 +++---- .../{sequence.hpp => Sequence.hpp} | 0 .../{wait_strategy.hpp => WaitStrategy.hpp} | 8 +- .../gnuradio-4.0/thread/thread_pool.hpp | 10 +- core/include/meson.build | 22 +-- core/test/qa_DynamicPort.cpp | 2 +- core/test/qa_buffer.cpp | 46 ++--- core/test/qa_settings.cpp | 2 +- core/test/qa_tags.cpp | 2 +- 27 files changed, 267 insertions(+), 271 deletions(-) rename core/benchmarks/{bm_buffer.cpp => bm_Buffer.cpp} (94%) rename core/benchmarks/{bm_history_buffer.cpp => bm_HistoryBuffer.cpp} (84%) rename core/benchmarks/{bm_profiler.cpp => bm_Profiler.cpp} (83%) rename core/benchmarks/{bm_scheduler.cpp => bm_Scheduler.cpp} (98%) rename core/include/gnuradio-4.0/{buffer.hpp => Buffer.hpp} (100%) rename core/include/gnuradio-4.0/{buffer_skeleton.hpp => BufferSkeleton.hpp} (84%) rename core/include/gnuradio-4.0/{circular_buffer.hpp => CircularBuffer.hpp} (97%) rename core/include/gnuradio-4.0/{claim_strategy.hpp => ClaimStrategy.hpp} (98%) rename core/include/gnuradio-4.0/{history_buffer.hpp => HistoryBuffer.hpp} (95%) rename core/include/gnuradio-4.0/{profiler.hpp => Profiler.hpp} (71%) rename core/include/gnuradio-4.0/{sequence.hpp => Sequence.hpp} (100%) rename core/include/gnuradio-4.0/{wait_strategy.hpp => WaitStrategy.hpp} (99%) diff --git a/blocks/basic/include/gnuradio-4.0/basic/data_sink.hpp b/blocks/basic/include/gnuradio-4.0/basic/data_sink.hpp index 3af65911f..9ab8c9862 100644 --- a/blocks/basic/include/gnuradio-4.0/basic/data_sink.hpp +++ b/blocks/basic/include/gnuradio-4.0/basic/data_sink.hpp @@ -2,9 +2,9 @@ #define GNURADIO_DATA_SINK_HPP #include -#include +#include #include -#include +#include #include #include @@ -309,7 +309,7 @@ class data_sink : public Block> { static constexpr std::size_t _listener_buffer_size = 65536; std::deque> _listeners; std::mutex _listener_mutex; - std::optional> _history; + std::optional> _history; bool _has_signal_info_from_settings = false; public: @@ -323,10 +323,10 @@ class data_sink : public Block> { struct poller { // TODO consider whether reusing port here makes sense - gr::circular_buffer buffer = gr::circular_buffer(_listener_buffer_size); + gr::CircularBuffer buffer = gr::CircularBuffer(_listener_buffer_size); decltype(buffer.new_reader()) reader = buffer.new_reader(); decltype(buffer.new_writer()) writer = buffer.new_writer(); - gr::circular_buffer tag_buffer = gr::circular_buffer(1024); + gr::CircularBuffer tag_buffer = gr::CircularBuffer(1024); decltype(tag_buffer.new_reader()) tag_reader = tag_buffer.new_reader(); decltype(tag_buffer.new_writer()) tag_writer = tag_buffer.new_writer(); std::size_t samples_read = 0; // reader thread @@ -363,12 +363,12 @@ class data_sink : public Block> { }; struct dataset_poller { - gr::circular_buffer> buffer = gr::circular_buffer>(_listener_buffer_size); - decltype(buffer.new_reader()) reader = buffer.new_reader(); - decltype(buffer.new_writer()) writer = buffer.new_writer(); + gr::CircularBuffer> buffer = gr::CircularBuffer>(_listener_buffer_size); + decltype(buffer.new_reader()) reader = buffer.new_reader(); + decltype(buffer.new_writer()) writer = buffer.new_writer(); - std::atomic finished = false; - std::atomic drop_count = 0; + std::atomic finished = false; + std::atomic drop_count = 0; [[nodiscard]] bool process(std::invocable>> auto fnc) { @@ -572,7 +572,7 @@ class data_sink : public Block> { // transitional, do not reallocate/copy, but create a shared buffer with size N, // and a per-listener history buffer where more than N samples is needed. - auto new_history = gr::history_buffer(new_size); + auto new_history = gr::HistoryBuffer(new_size); if (_history) { new_history.push_back_bulk(_history->begin(), _history->end()); } diff --git a/blocks/basic/test/qa_data_sink.cpp b/blocks/basic/test/qa_data_sink.cpp index 003634d72..ca31dd1bd 100644 --- a/blocks/basic/test/qa_data_sink.cpp +++ b/blocks/basic/test/qa_data_sink.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/blocks/filter/include/gnuradio-4.0/filter/time_domain_filter.hpp b/blocks/filter/include/gnuradio-4.0/filter/time_domain_filter.hpp index b5bf3d83b..360ea1831 100644 --- a/blocks/filter/include/gnuradio-4.0/filter/time_domain_filter.hpp +++ b/blocks/filter/include/gnuradio-4.0/filter/time_domain_filter.hpp @@ -3,7 +3,7 @@ #include #include -#include +#include namespace gr::filter { @@ -17,15 +17,15 @@ struct fir_filter : Block, Doc> { - PortIn in; - PortOut out; - std::vector b{}; // feedforward coefficients - history_buffer inputHistory{ 32 }; + PortIn in; + PortOut out; + std::vector b{}; // feedforward coefficients + HistoryBuffer inputHistory{ 32 }; void settings_changed(const property_map & /*old_settings*/, const property_map &new_settings) noexcept { if (new_settings.contains("b") && b.size() >= inputHistory.capacity()) { - inputHistory = history_buffer(std::bit_ceil(b.size())); + inputHistory = HistoryBuffer(std::bit_ceil(b.size())); } } @@ -51,19 +51,19 @@ struct iir_filter : Block, Doc> { - PortIn in; - PortOut out; - std::vector b{ 1 }; // feed-forward coefficients - std::vector a{ 1 }; // feedback coefficients - history_buffer inputHistory{ 32 }; - history_buffer outputHistory{ 32 }; + PortIn in; + PortOut out; + std::vector b{ 1 }; // feed-forward coefficients + std::vector a{ 1 }; // feedback coefficients + HistoryBuffer inputHistory{ 32 }; + HistoryBuffer outputHistory{ 32 }; void settings_changed(const property_map & /*old_settings*/, const property_map &new_settings) noexcept { const auto new_size = std::max(a.size(), b.size()); if ((new_settings.contains("b") || new_settings.contains("a")) && (new_size >= inputHistory.capacity() || new_size >= inputHistory.capacity())) { - inputHistory = history_buffer(std::bit_ceil(new_size)); - outputHistory = history_buffer(std::bit_ceil(new_size)); + inputHistory = HistoryBuffer(std::bit_ceil(new_size)); + outputHistory = HistoryBuffer(std::bit_ceil(new_size)); } } diff --git a/blocks/fourier/include/gnuradio-4.0/fourier/fft.hpp b/blocks/fourier/include/gnuradio-4.0/fourier/fft.hpp index 2858a0b10..8a2a97c2b 100644 --- a/blocks/fourier/include/gnuradio-4.0/fourier/fft.hpp +++ b/blocks/fourier/include/gnuradio-4.0/fourier/fft.hpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include diff --git a/core/benchmarks/CMakeLists.txt b/core/benchmarks/CMakeLists.txt index d7c486538..d82d6ab7b 100644 --- a/core/benchmarks/CMakeLists.txt +++ b/core/benchmarks/CMakeLists.txt @@ -3,10 +3,10 @@ function (add_gr_benchmark BM_NAME) target_link_libraries(${BM_NAME} PRIVATE gnuradio-core refl-cpp fmt gr-basic gr-testing) endfunction() -add_gr_benchmark(bm_buffer) -add_gr_benchmark(bm_history_buffer) -add_gr_benchmark(bm_profiler) -add_gr_benchmark(bm_scheduler) +add_gr_benchmark(bm_Buffer) +add_gr_benchmark(bm_HistoryBuffer) +add_gr_benchmark(bm_Profiler) +add_gr_benchmark(bm_Scheduler) add_gr_benchmark(bm_node_api) add_gr_benchmark(bm_fft) target_link_libraries(bm_fft PRIVATE gr-fourier) diff --git a/core/benchmarks/bm_buffer.cpp b/core/benchmarks/bm_Buffer.cpp similarity index 94% rename from core/benchmarks/bm_buffer.cpp rename to core/benchmarks/bm_Buffer.cpp index cd87225c7..9a9fc4ebb 100644 --- a/core/benchmarks/bm_buffer.cpp +++ b/core/benchmarks/bm_Buffer.cpp @@ -7,9 +7,9 @@ #include -#include // new buffer header interface -#include -#include +#include // new buffer header interface +#include +#include #include @@ -149,11 +149,11 @@ inline const boost::ut::suite _buffer_tests = [] { } }; if (nP == 1) { - using BufferType = circular_buffer; + using BufferType = CircularBuffer; Buffer auto buffer = is_posix ? BufferType(size) : BufferType(size, allocator); invoke(buffer); } else { - using BufferType = circular_buffer; + using BufferType = CircularBuffer; Buffer auto buffer = is_posix ? BufferType(size) : BufferType(size, allocator); invoke(buffer); } diff --git a/core/benchmarks/bm_history_buffer.cpp b/core/benchmarks/bm_HistoryBuffer.cpp similarity index 84% rename from core/benchmarks/bm_history_buffer.cpp rename to core/benchmarks/bm_HistoryBuffer.cpp index ea77ffdc3..0cc3355e1 100644 --- a/core/benchmarks/bm_history_buffer.cpp +++ b/core/benchmarks/bm_HistoryBuffer.cpp @@ -6,8 +6,8 @@ #include -#include -#include +#include +#include #include inline const boost::ut::suite _buffer_tests = [] { @@ -17,9 +17,9 @@ inline const boost::ut::suite _buffer_tests = [] { using namespace gr; { - circular_buffer buffer(32); - auto writer = buffer.new_writer(); - auto reader = buffer.new_reader(); + CircularBuffer buffer(32); + auto writer = buffer.new_writer(); + auto reader = buffer.new_reader(); "circular_buffer(32) - multiple producer"_benchmark.repeat(samples) = [&writer, &reader] { static int counter = 0; @@ -34,9 +34,9 @@ inline const boost::ut::suite _buffer_tests = [] { }; } { - circular_buffer buffer(32); - auto writer = buffer.new_writer(); - auto reader = buffer.new_reader(); + CircularBuffer buffer(32); + auto writer = buffer.new_writer(); + auto reader = buffer.new_reader(); "circular_buffer(32) - single producer via lambda"_benchmark.repeat(samples) = [&writer, &reader] { static int counter = 0; @@ -51,9 +51,9 @@ inline const boost::ut::suite _buffer_tests = [] { }; } { - circular_buffer buffer(32); - auto writer = buffer.new_writer(); - auto reader = buffer.new_reader(); + CircularBuffer buffer(32); + auto writer = buffer.new_writer(); + auto reader = buffer.new_reader(); "circular_buffer(32) - single producer via reserve"_benchmark.repeat(samples) = [&writer, &reader] { static int counter = 0; @@ -73,7 +73,7 @@ inline const boost::ut::suite _buffer_tests = [] { * left intentionally some space to improve the circular_buffer implementation here */ { - history_buffer buffer(32); + HistoryBuffer buffer(32); "history_buffer(32)"_benchmark.repeat(samples) = [&buffer] { static int counter = 0; @@ -87,7 +87,7 @@ inline const boost::ut::suite _buffer_tests = [] { }; } { - history_buffer buffer(32); + HistoryBuffer buffer(32); "history_buffer"_benchmark.repeat(samples) = [&buffer] { static int counter = 0; @@ -102,9 +102,9 @@ inline const boost::ut::suite _buffer_tests = [] { } { - circular_buffer buffer(32); - auto writer = buffer.new_writer(); - auto reader = buffer.new_reader(); + CircularBuffer buffer(32); + auto writer = buffer.new_writer(); + auto reader = buffer.new_reader(); "circular_buffer(32) - no checks"_benchmark.repeat(samples) = [&writer, &reader] { static int counter = 0; @@ -119,7 +119,7 @@ inline const boost::ut::suite _buffer_tests = [] { }; } { - history_buffer buffer; + HistoryBuffer buffer; "history_buffer - no checks"_benchmark.repeat(samples) = [&buffer] { static int counter = 0; @@ -131,7 +131,7 @@ inline const boost::ut::suite _buffer_tests = [] { }; } { - history_buffer buffer(32); + HistoryBuffer buffer(32); "history_buffer(32) - no checks"_benchmark.repeat(samples) = [&buffer] { static int counter = 0; diff --git a/core/benchmarks/bm_profiler.cpp b/core/benchmarks/bm_Profiler.cpp similarity index 83% rename from core/benchmarks/bm_profiler.cpp rename to core/benchmarks/bm_Profiler.cpp index e2ad7889b..ce8b0e397 100644 --- a/core/benchmarks/bm_profiler.cpp +++ b/core/benchmarks/bm_Profiler.cpp @@ -1,6 +1,6 @@ #include -#include +#include using namespace gr::profiling; @@ -24,16 +24,16 @@ run_without_profiler() { fmt::print("The sum of sums is {} and it took {}ms\n", r, std::chrono::duration_cast(elapsed).count()); } -template +template inline void -run_with_profiler(P &p) { +run_with_profiler(TProfiler &p) { const auto start = detail::clock::now(); - auto &handler = p.for_this_thread(); + auto &handler = p.forThisThread(); - [[maybe_unused]] auto whole_calculation_event = handler.start_complete_event("whole_calculation"); + [[maybe_unused]] auto whole_calculation_event = handler.startCompleteEvent("whole_calculation"); long long r = 0; for (std::size_t i = 0; i < 1000; ++i) { - auto async_event = handler.start_async_event("iteration", {}, { { "arg1", 2 }, { "arg2", "hello" } }); + auto async_event = handler.startAsyncEvent("iteration", {}, { { "arg1", 2 }, { "arg2", "hello" } }); for (std::size_t j = 0; j < 1000; ++j) { std::vector v(10000); std::iota(v.begin(), v.end(), 1); @@ -50,10 +50,10 @@ run_with_profiler(P &p) { using namespace boost::ut; using namespace benchmark; - profiler prof; + Profiler prof; "default profiler"_benchmark.repeat(N_SAMPLES) = [&p = prof] { run_with_profiler(p); }; - null::profiler null_prof; + null::Profiler null_prof; "null profiler"_benchmark.repeat(N_SAMPLES) = [&p = null_prof] { run_with_profiler(p); }; "no profiler"_benchmark.repeat(N_SAMPLES) = [] { run_without_profiler(); }; diff --git a/core/benchmarks/bm_scheduler.cpp b/core/benchmarks/bm_Scheduler.cpp similarity index 98% rename from core/benchmarks/bm_scheduler.cpp rename to core/benchmarks/bm_Scheduler.cpp index b8e498cb5..264f6f38b 100644 --- a/core/benchmarks/bm_scheduler.cpp +++ b/core/benchmarks/bm_Scheduler.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include @@ -139,7 +139,7 @@ exec_bm(auto &scheduler, const std::string &test_case) { gr::scheduler::BreadthFirst sched4_mt(test_graph_bifurcated(N_NODES), pool); "bifurcated graph - BFS scheduler (multi-threaded)"_benchmark.repeat(N_SAMPLES) = [&sched4_mt]() { exec_bm(sched4_mt, "bifurcated-graph BFS-sched (multi-threaded)"); }; - gr::scheduler::BreadthFirst sched4_mt_prof(test_graph_bifurcated(N_NODES), pool); + gr::scheduler::BreadthFirst sched4_mt_prof(test_graph_bifurcated(N_NODES), pool); "bifurcated graph - BFS scheduler (multi-threaded) with profiling"_benchmark.repeat(N_SAMPLES) = [&sched4_mt_prof]() { exec_bm(sched4_mt_prof, "bifurcated-graph BFS-sched (multi-threaded) with profiling"); }; diff --git a/core/include/gnuradio-4.0/Block.hpp b/core/include/gnuradio-4.0/Block.hpp index 24d48c8c8..419392105 100644 --- a/core/include/gnuradio-4.0/Block.hpp +++ b/core/include/gnuradio-4.0/Block.hpp @@ -9,7 +9,7 @@ #include "BlockTraits.hpp" #include "Port.hpp" -#include "sequence.hpp" +#include "Sequence.hpp" #include "tag.hpp" #include "thread/thread_pool.hpp" diff --git a/core/include/gnuradio-4.0/buffer.hpp b/core/include/gnuradio-4.0/Buffer.hpp similarity index 100% rename from core/include/gnuradio-4.0/buffer.hpp rename to core/include/gnuradio-4.0/Buffer.hpp diff --git a/core/include/gnuradio-4.0/buffer_skeleton.hpp b/core/include/gnuradio-4.0/BufferSkeleton.hpp similarity index 84% rename from core/include/gnuradio-4.0/buffer_skeleton.hpp rename to core/include/gnuradio-4.0/BufferSkeleton.hpp index b7080a737..5f23716f3 100644 --- a/core/include/gnuradio-4.0/buffer_skeleton.hpp +++ b/core/include/gnuradio-4.0/BufferSkeleton.hpp @@ -1,5 +1,5 @@ -#ifndef GNURADIO_BUFFER_SKELETON_HPP -#define GNURADIO_BUFFER_SKELETON_HPP +#ifndef GNURADIO_BUFFERSKELETON_HPP +#define GNURADIO_BUFFERSKELETON_HPP #ifndef GNURADIO_BUFFER2_H #include "buffer.hpp" // TODO: why is this include guard outside of the buffer hpp needed? @@ -18,7 +18,7 @@ namespace gr::test { * @tparam T the internally stored type parameter */ template -class buffer_skeleton { +class BufferSkeleton { struct buffer_impl { const std::size_t _size; std::vector _data; @@ -36,12 +36,12 @@ class buffer_skeleton { explicit buffer_reader(std::shared_ptr buffer) : _buffer(buffer) {} - friend buffer_skeleton; + friend BufferSkeleton; public: - [[nodiscard]] buffer_skeleton + [[nodiscard]] BufferSkeleton buffer() const noexcept { - return buffer_skeleton(_buffer); + return BufferSkeleton(_buffer); }; template @@ -75,12 +75,12 @@ class buffer_skeleton { explicit buffer_writer(std::shared_ptr buffer) : _buffer(buffer) {} - friend buffer_skeleton; + friend BufferSkeleton; public: - [[nodiscard]] buffer_skeleton + [[nodiscard]] BufferSkeleton buffer() const noexcept { - return buffer_skeleton(_buffer); + return BufferSkeleton(_buffer); }; [[nodiscard]] constexpr auto @@ -113,14 +113,14 @@ class buffer_skeleton { // or generating buffer itself std::shared_ptr _shared_buffer_ptr; - explicit buffer_skeleton(std::shared_ptr shared_buffer_ptr) : _shared_buffer_ptr(shared_buffer_ptr) {} + explicit BufferSkeleton(std::shared_ptr shared_buffer_ptr) : _shared_buffer_ptr(shared_buffer_ptr) {} public: - buffer_skeleton() = delete; + BufferSkeleton() = delete; - explicit buffer_skeleton(const std::size_t min_size) : _shared_buffer_ptr(std::make_shared(min_size)) {} + explicit BufferSkeleton(const std::size_t min_size) : _shared_buffer_ptr(std::make_shared(min_size)) {} - ~buffer_skeleton() = default; + ~BufferSkeleton() = default; [[nodiscard]] std::size_t size() const { @@ -140,8 +140,8 @@ class buffer_skeleton { } }; -static_assert(Buffer>); +static_assert(Buffer>); } // namespace gr::test -#endif // GNURADIO_BUFFER_SKELETON_HPP +#endif // GNURADIO_BUFFERSKELETON_HPP diff --git a/core/include/gnuradio-4.0/circular_buffer.hpp b/core/include/gnuradio-4.0/CircularBuffer.hpp similarity index 97% rename from core/include/gnuradio-4.0/circular_buffer.hpp rename to core/include/gnuradio-4.0/CircularBuffer.hpp index 747a09cc1..0cad506e8 100644 --- a/core/include/gnuradio-4.0/circular_buffer.hpp +++ b/core/include/gnuradio-4.0/CircularBuffer.hpp @@ -1,5 +1,5 @@ -#ifndef GNURADIO_CIRCULAR_BUFFER_HPP -#define GNURADIO_CIRCULAR_BUFFER_HPP +#ifndef GNURADIO_CIRCULARBUFFER_HPP +#define GNURADIO_CIRCULARBUFFER_HPP #if defined(_LIBCPP_VERSION) and _LIBCPP_VERSION < 16000 #include @@ -51,10 +51,10 @@ static constexpr bool has_posix_mmap_interface = false; } #endif -#include "buffer.hpp" -#include "claim_strategy.hpp" -#include "sequence.hpp" -#include "wait_strategy.hpp" +#include "Buffer.hpp" +#include "ClaimStrategy.hpp" +#include "Sequence.hpp" +#include "WaitStrategy.hpp" namespace gr { @@ -216,10 +216,10 @@ class double_mapped_memory_resource : public std::pmr::memory_resource { * for more details see */ template -class circular_buffer +class CircularBuffer { using Allocator = std::pmr::polymorphic_allocator; - using BufferType = circular_buffer; + using BufferType = CircularBuffer; using ClaimType = detail::producer_type_v; using DependendsType = std::shared_ptr>>; using signed_index_type = Sequence::signed_index_type; @@ -388,7 +388,7 @@ class circular_buffer return *this; } - [[nodiscard]] constexpr BufferType buffer() const noexcept { return circular_buffer(_buffer); }; + [[nodiscard]] constexpr BufferType buffer() const noexcept { return CircularBuffer(_buffer); }; [[nodiscard]] constexpr auto reserve_output_range(std::size_t n_slots_to_claim) noexcept -> ReservedOutputRange { try { @@ -499,7 +499,7 @@ class circular_buffer }; ~buffer_reader() { gr::detail::removeSequence( _buffer->_read_indices, _read_index); } - [[nodiscard]] constexpr BufferType buffer() const noexcept { return circular_buffer(_buffer); }; + [[nodiscard]] constexpr BufferType buffer() const noexcept { return CircularBuffer(_buffer); }; template [[nodiscard]] constexpr std::span get(const std::size_t n_requested = 0) const noexcept { @@ -542,13 +542,13 @@ class circular_buffer } std::shared_ptr _shared_buffer_ptr; - explicit circular_buffer(std::shared_ptr shared_buffer_ptr) : _shared_buffer_ptr(shared_buffer_ptr) {} + explicit CircularBuffer(std::shared_ptr shared_buffer_ptr) : _shared_buffer_ptr(shared_buffer_ptr) {} public: - circular_buffer() = delete; - explicit circular_buffer(std::size_t min_size, Allocator allocator = DefaultAllocator()) + CircularBuffer() = delete; + explicit CircularBuffer(std::size_t min_size, Allocator allocator = DefaultAllocator()) : _shared_buffer_ptr(std::make_shared(min_size, allocator)) { } - ~circular_buffer() = default; + ~CircularBuffer() = default; [[nodiscard]] std::size_t size() const noexcept { return _shared_buffer_ptr->_size; } [[nodiscard]] BufferWriter auto new_writer() { return buffer_writer(_shared_buffer_ptr); } @@ -561,9 +561,9 @@ class circular_buffer [[nodiscard]] const auto &cursor_sequence() { return _shared_buffer_ptr->_cursor; } }; -static_assert(Buffer>); +static_assert(Buffer>); // clang-format on } // namespace gr -#endif // GNURADIO_CIRCULAR_BUFFER_HPP +#endif // GNURADIO_CIRCULARBUFFER_HPP diff --git a/core/include/gnuradio-4.0/claim_strategy.hpp b/core/include/gnuradio-4.0/ClaimStrategy.hpp similarity index 98% rename from core/include/gnuradio-4.0/claim_strategy.hpp rename to core/include/gnuradio-4.0/ClaimStrategy.hpp index 8c65aadff..9d6f24bf0 100644 --- a/core/include/gnuradio-4.0/claim_strategy.hpp +++ b/core/include/gnuradio-4.0/ClaimStrategy.hpp @@ -1,5 +1,5 @@ -#ifndef GNURADIO_CLAIM_STRATEGY_HPP -#define GNURADIO_CLAIM_STRATEGY_HPP +#ifndef GNURADIO_CLAIMSTRATEGY_HPP +#define GNURADIO_CLAIMSTRATEGY_HPP #include #include @@ -11,8 +11,8 @@ #include -#include "sequence.hpp" -#include "wait_strategy.hpp" +#include "Sequence.hpp" +#include "WaitStrategy.hpp" namespace gr { @@ -323,4 +323,4 @@ using producer_type_v = typename producer_type #include "Block.hpp" -#include "buffer.hpp" -#include "circular_buffer.hpp" +#include "Buffer.hpp" +#include "CircularBuffer.hpp" #include "Port.hpp" -#include "sequence.hpp" +#include "Sequence.hpp" #include "thread/thread_pool.hpp" #include @@ -434,7 +434,7 @@ struct Graph { template [[nodiscard]] ConnectionResult connectImpl(Source &src_block_raw, SourcePort &source_port, Destination &dst_block_raw, DestinationPort &destination_port, std::size_t min_buffer_size = 65536, std::int32_t weight = 0, - std::string_view name = "unnamed edge") { + std::string_view name = "unnamed edge") { static_assert(std::is_same_v, "The source port type needs to match the sink port type"); if (!std::any_of(_blocks.begin(), _blocks.end(), [&](const auto ®istered_block) { return registered_block->raw() == std::addressof(src_block_raw); }) diff --git a/core/include/gnuradio-4.0/history_buffer.hpp b/core/include/gnuradio-4.0/HistoryBuffer.hpp similarity index 95% rename from core/include/gnuradio-4.0/history_buffer.hpp rename to core/include/gnuradio-4.0/HistoryBuffer.hpp index 9a47a0167..feed1c2e1 100644 --- a/core/include/gnuradio-4.0/history_buffer.hpp +++ b/core/include/gnuradio-4.0/HistoryBuffer.hpp @@ -1,5 +1,5 @@ -#ifndef GNURADIO_HISTORY_BUFFER_HPP -#define GNURADIO_HISTORY_BUFFER_HPP +#ifndef GNURADIO_HISTORYBUFFER_HPP +#define GNURADIO_HISTORYBUFFER_HPP #include #include @@ -42,7 +42,7 @@ namespace gr { * buffer.get_span(1); // span: [2, 3, 4, 5] */ template> -class history_buffer { +class HistoryBuffer { using signed_index_type = std::make_signed_t; using buffer_type = typename std::conditional_t, std::array>; using size_type = typename std::conditional_t; @@ -65,9 +65,9 @@ class history_buffer { } public: - constexpr explicit history_buffer() noexcept { static_assert(N != std::dynamic_extent, "need to specify capacity"); } + constexpr explicit HistoryBuffer() noexcept { static_assert(N != std::dynamic_extent, "need to specify capacity"); } - constexpr explicit history_buffer(size_t capacity) : _buffer(capacity * 2), _capacity(capacity) { + constexpr explicit HistoryBuffer(size_t capacity) : _buffer(capacity * 2), _capacity(capacity) { if (capacity == 0) { throw std::out_of_range("capacity is zero"); } @@ -221,4 +221,4 @@ class history_buffer { } // namespace gr -#endif // GNURADIO_HISTORY_BUFFER_HPP +#endif // GNURADIO_HISTORYBUFFER_HPP diff --git a/core/include/gnuradio-4.0/Port.hpp b/core/include/gnuradio-4.0/Port.hpp index 10a2f7822..94d61a775 100644 --- a/core/include/gnuradio-4.0/Port.hpp +++ b/core/include/gnuradio-4.0/Port.hpp @@ -9,7 +9,7 @@ #include "annotated.hpp" #include "Block.hpp" -#include "circular_buffer.hpp" +#include "CircularBuffer.hpp" #include "dataset.hpp" #include "tag.hpp" @@ -151,9 +151,9 @@ template using is_tag_buffer_attribute = std::bool_constant>; template -struct DefaultStreamBuffer : StreamBufferType> {}; +struct DefaultStreamBuffer : StreamBufferType> {}; -struct DefaultTagBuffer : TagBufferType> {}; +struct DefaultTagBuffer : TagBufferType> {}; static_assert(is_stream_buffer_attribute>::value); static_assert(!is_stream_buffer_attribute::value); diff --git a/core/include/gnuradio-4.0/profiler.hpp b/core/include/gnuradio-4.0/Profiler.hpp similarity index 71% rename from core/include/gnuradio-4.0/profiler.hpp rename to core/include/gnuradio-4.0/Profiler.hpp index 3ef457f6c..3a0e20a70 100644 --- a/core/include/gnuradio-4.0/profiler.hpp +++ b/core/include/gnuradio-4.0/Profiler.hpp @@ -1,7 +1,7 @@ -#ifndef GNURADIO_PROFILER_H -#define GNURADIO_PROFILER_H +#ifndef GNURADIO_PROFILER_HPP +#define GNURADIO_PROFILER_HPP -#include "circular_buffer.hpp" +#include "CircularBuffer.hpp" #include @@ -126,17 +126,17 @@ concept StepEvent = requires(T e) { }; template -concept ProfilerHandler = requires(T h, std::string_view name, std::string_view categories, std::initializer_list args) { - { h.start_complete_event(name, categories, args) } -> SimpleEvent; - { h.start_async_event(name, categories, args) } -> StepEvent; - { h.instant_event(name, categories, args) } -> std::same_as; - { h.counter_event(name, categories, args) } -> std::same_as; +concept ProfilerHandlerLike = requires(T h, std::string_view name, std::string_view categories, std::initializer_list args) { + { h.startCompleteEvent(name, categories, args) } -> SimpleEvent; + { h.startAsyncEvent(name, categories, args) } -> StepEvent; + { h.instantEvent(name, categories, args) } -> std::same_as; + { h.counterEvent(name, categories, args) } -> std::same_as; }; template -concept Profiler = requires(T p) { +concept ProfilerLike = requires(T p) { { p.reset() } -> std::same_as; - { p.for_this_thread() } -> ProfilerHandler; + { p.forThisThread() } -> ProfilerHandlerLike; }; enum class output_mode_t { StdOut, File }; @@ -147,7 +147,7 @@ struct options { }; namespace null { -class step_event { +class StepEvent { public: constexpr void step() const noexcept {} @@ -156,56 +156,56 @@ class step_event { finish() const noexcept {} }; -class simple_event { +class SimpleEvent { public: constexpr void finish() const noexcept {} }; -class handler { +class Handler { public: constexpr void - instant_event(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) const noexcept { + instantEvent(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) const noexcept { std::ignore = name; std::ignore = categories; std::ignore = args; } constexpr void - counter_event(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) const noexcept { + counterEvent(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) const noexcept { std::ignore = name; std::ignore = categories; std::ignore = args; } - [[nodiscard]] constexpr simple_event - start_complete_event(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) const noexcept { + [[nodiscard]] constexpr SimpleEvent + startCompleteEvent(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) const noexcept { std::ignore = name; std::ignore = categories; std::ignore = args; - return simple_event{}; + return SimpleEvent{}; } - [[nodiscard]] constexpr step_event - start_async_event(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) const noexcept { + [[nodiscard]] constexpr StepEvent + startAsyncEvent(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) const noexcept { std::ignore = name; std::ignore = categories; std::ignore = args; - return step_event{}; + return StepEvent{}; } }; -class profiler { - handler _handler; +class Profiler { + Handler _handler; public: - constexpr explicit profiler(const options & = {}) {} + constexpr explicit Profiler(const options & = {}) {} constexpr void reset() const {} - constexpr handler & - for_this_thread() { + constexpr Handler & + forThisThread() { return _handler; } }; @@ -213,7 +213,7 @@ class profiler { } // namespace null template -class complete_event { +class CompleteEvent { Handler &_handler; std::string _name; std::string _categories; @@ -222,18 +222,18 @@ class complete_event { detail::time_point _start = detail::clock::now(); public: - explicit complete_event(Handler &handler, std::string_view name, std::string_view categories, std::initializer_list args) + explicit CompleteEvent(Handler &handler, std::string_view name, std::string_view categories, std::initializer_list args) : _handler{ handler }, _name{ name }, _categories{ categories }, _args{ args } {} - ~complete_event() { finish(); } + ~CompleteEvent() { finish(); } - complete_event(const complete_event &) = delete; - complete_event & - operator=(const complete_event &) + CompleteEvent(const CompleteEvent &) = delete; + CompleteEvent & + operator=(const CompleteEvent &) = delete; - complete_event(complete_event &&) noexcept = default; - complete_event & - operator=(complete_event &&) noexcept + CompleteEvent(CompleteEvent &&) noexcept = default; + CompleteEvent & + operator=(CompleteEvent &&) noexcept = default; void @@ -242,10 +242,10 @@ class complete_event { return; } const auto elapsed = detail::clock::now() - _start; - auto r = _handler.reserve_event(); + auto r = _handler.reserveEvent(); r[0].name = _name; r[0].type = detail::EventType::Complete; - r[0].ts = std::chrono::duration_cast(_start - _handler.profiler().start()); + r[0].ts = std::chrono::duration_cast(_start - _handler.Profiler().start()); r[0].dur = std::chrono::duration_cast(elapsed); r[0].cat = _categories; r[0].args = _args; @@ -255,31 +255,31 @@ class complete_event { }; template -class async_event { +class AsyncEvent { Handler &_handler; bool _finished = false; int _id; std::string _name; public: - explicit async_event(Handler &handler, std::string_view name, int id, std::string_view categories = {}, std::initializer_list args = {}) : _handler(handler), _id{ id }, _name{ name } { - post_event(detail::EventType::AsyncStart, categories, args); + explicit AsyncEvent(Handler &handler, std::string_view name, int id, std::string_view categories = {}, std::initializer_list args = {}) : _handler(handler), _id{ id }, _name{ name } { + postEvent(detail::EventType::AsyncStart, categories, args); } - ~async_event() { finish(); } + ~AsyncEvent() { finish(); } - async_event(const async_event &) = delete; - async_event & - operator=(const async_event &) + AsyncEvent(const AsyncEvent &) = delete; + AsyncEvent & + operator=(const AsyncEvent &) = delete; - async_event(async_event &&) noexcept = default; - async_event & - operator=(async_event &&) noexcept + AsyncEvent(AsyncEvent &&) noexcept = default; + AsyncEvent & + operator=(AsyncEvent &&) noexcept = default; void step() noexcept { - post_event(detail::EventType::AsyncStep); + postEvent(detail::EventType::AsyncStep); } void @@ -287,14 +287,14 @@ class async_event { if (_finished) { return; } - post_event(detail::EventType::AsyncEnd); + postEvent(detail::EventType::AsyncEnd); _finished = true; } private: void - post_event(detail::EventType type, std::string_view categories = {}, std::initializer_list args = {}) noexcept { - auto r = _handler.reserve_event(); + postEvent(detail::EventType type, std::string_view categories = {}, std::initializer_list args = {}) noexcept { + auto r = _handler.reserveEvent(); r[0].name = _name; r[0].type = type; r[0].id = _id; @@ -304,32 +304,32 @@ class async_event { } }; -template -class handler { - using this_t = handler; - Profiler &_profiler; - WriterType _writer; +template +class Handler { + using this_t = Handler; + TProfiler &_profiler; + TWriterType _writer; int _nextId = 1; public: - explicit handler(Profiler &profiler, WriterType &&writer) : _profiler(profiler), _writer{ std::move(writer) } {} + explicit Handler(TProfiler &profiler, TWriterType &&writer) : _profiler(profiler), _writer{ std::move(writer) } {} - handler(const this_t &) = delete; + Handler(const this_t &) = delete; this_t & operator=(const this_t &) = delete; - handler(this_t &&) noexcept = delete; + Handler(this_t &&) noexcept = delete; this_t & operator=(this_t &&) noexcept = delete; - const Profiler & - profiler() const { + const TProfiler & + Profiler() const { return _profiler; } auto - reserve_event() noexcept { + reserveEvent() noexcept { const auto elapsed = detail::clock::now() - _profiler.start(); auto r = _writer.reserve_output_range(1); r[0].thread_id = std::this_thread::get_id(); @@ -338,8 +338,8 @@ class handler { } void - instant_event(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) noexcept { - auto r = reserve_event(); + instantEvent(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) noexcept { + auto r = reserveEvent(); r[0].name = std::string{ name }; r[0].type = detail::EventType::Instant; r[0].cat = std::string{ categories }; @@ -348,8 +348,8 @@ class handler { } void - counter_event(std::string_view name, std::string_view categories, std::initializer_list args = {}) noexcept { - auto r = reserve_event(); + counterEvent(std::string_view name, std::string_view categories, std::initializer_list args = {}) noexcept { + auto r = reserveEvent(); r[0].name = std::string{ name }; r[0].type = detail::EventType::Counter; r[0].cat = std::string{ categories }; @@ -357,23 +357,23 @@ class handler { r.publish(1); } - [[nodiscard]] complete_event - start_complete_event(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) noexcept { - return complete_event{ *this, name, categories, args }; + [[nodiscard]] CompleteEvent + startCompleteEvent(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) noexcept { + return CompleteEvent{ *this, name, categories, args }; } - [[nodiscard]] async_event - start_async_event(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) noexcept { + [[nodiscard]] AsyncEvent + startAsyncEvent(std::string_view name, std::string_view categories = {}, std::initializer_list args = {}) noexcept { const auto id = _nextId; ++_nextId; - return async_event{ *this, name, id, categories, args }; + return AsyncEvent{ *this, name, id, categories, args }; } }; -class profiler { - gr::circular_buffer _buffer; +class Profiler { + gr::CircularBuffer _buffer; using WriterType = decltype(_buffer.new_writer()); - using HandlerType = handler; + using HandlerType = Handler; std::mutex _handlers_lock; std::map _handlers; std::atomic _finished = false; @@ -382,7 +382,7 @@ class profiler { detail::time_point _start = detail::clock::now(); public: - explicit profiler(const options &options = {}) : _buffer(500000) { + explicit Profiler(const options &options = {}) : _buffer(500000) { _event_handler = std::thread([options, &reader = _reader, &finished = _finished]() { auto file_name = options.output_file; std::ofstream out_file; @@ -424,7 +424,7 @@ class profiler { reset(); } - ~profiler() { + ~Profiler() { _finished = true; _event_handler.join(); } @@ -439,8 +439,8 @@ class profiler { _start = detail::clock::now(); } - handler & - for_this_thread() { + Handler & + forThisThread() { const auto this_id = std::this_thread::get_id(); const std::lock_guard lock{ _handlers_lock }; auto it = _handlers.find(this_id); @@ -455,4 +455,4 @@ class profiler { } // namespace gr::profiling -#endif // include guard +#endif // include guard GNURADIO_PROFILER_HPP diff --git a/core/include/gnuradio-4.0/Scheduler.hpp b/core/include/gnuradio-4.0/Scheduler.hpp index f7ea4292a..558d7fccc 100644 --- a/core/include/gnuradio-4.0/Scheduler.hpp +++ b/core/include/gnuradio-4.0/Scheduler.hpp @@ -7,7 +7,7 @@ #include #include "Graph.hpp" -#include "profiler.hpp" +#include "Profiler.hpp" #include "thread/thread_pool.hpp" namespace gr::scheduler { @@ -17,22 +17,22 @@ enum ExecutionPolicy { singleThreaded, multiThreaded }; enum SchedulerState { IDLE, INITIALISED, RUNNING, REQUESTED_STOP, REQUESTED_PAUSE, STOPPED, PAUSED, SHUTTING_DOWN, ERROR }; -template +template class SchedulerBase { protected: - SchedulerState _state = IDLE; - gr::Graph _graph; - Profiler _profiler; - decltype(_profiler.for_this_thread()) _profiler_handler; - std::shared_ptr _pool; - std::atomic_uint64_t _progress; - std::atomic_size_t _running_threads; - std::atomic_bool _stop_requested; + SchedulerState _state = IDLE; + gr::Graph _graph; + TProfiler _profiler; + decltype(_profiler.forThisThread()) _profiler_handler; + std::shared_ptr _pool; + std::atomic_uint64_t _progress; + std::atomic_size_t _running_threads; + std::atomic_bool _stop_requested; public: explicit SchedulerBase(gr::Graph &&graph, std::shared_ptr thread_pool = std::make_shared("simple-scheduler-pool", thread_pool::CPU_BOUND), - const profiling::options &profiling_options = {}) - : _graph(std::move(graph)), _profiler{ profiling_options }, _profiler_handler{ _profiler.for_this_thread() }, _pool(std::move(thread_pool)) {} + const profiling::options &profiling_options = {}) + : _graph(std::move(graph)), _profiler{ profiling_options }, _profiler_handler{ _profiler.forThisThread() }, _pool(std::move(thread_pool)) {} ~SchedulerBase() { stop(); @@ -65,7 +65,7 @@ class SchedulerBase { void waitDone() { - [[maybe_unused]] const auto pe = _profiler_handler.start_complete_event("scheduler_base.waitDone"); + [[maybe_unused]] const auto pe = _profiler_handler.startCompleteEvent("scheduler_base.waitDone"); for (auto running = _running_threads.load(); running > 0ul; running = _running_threads.load()) { _running_threads.wait(running); } @@ -90,7 +90,7 @@ class SchedulerBase { void init() { - [[maybe_unused]] const auto pe = _profiler_handler.start_complete_event("scheduler_base.init"); + [[maybe_unused]] const auto pe = _profiler_handler.startCompleteEvent("scheduler_base.init"); if (_state != IDLE) { return; } @@ -129,7 +129,7 @@ class SchedulerBase { void runOnPool(const std::vector> &jobs, const std::function &)> work_function) { - [[maybe_unused]] const auto pe = _profiler_handler.start_complete_event("scheduler_base.runOnPool"); + [[maybe_unused]] const auto pe = _profiler_handler.startCompleteEvent("scheduler_base.runOnPool"); _progress = 0; _running_threads = jobs.size(); for (auto &jobset : jobs) { @@ -139,12 +139,12 @@ class SchedulerBase { void poolWorker(const std::function &work, std::size_t n_batches) { - auto &profiler_handler = _profiler.for_this_thread(); + auto &profiler_handler = _profiler.forThisThread(); uint32_t done = 0; uint32_t progress_count = 0; while (done < n_batches && !_stop_requested) { - auto pe = profiler_handler.start_complete_event("scheduler_base.work"); + auto pe = profiler_handler.startCompleteEvent("scheduler_base.work"); bool something_happened = work().status == WorkReturnStatus::OK; pe.finish(); uint64_t progress_local, progress_new; @@ -182,19 +182,19 @@ class SchedulerBase { /** * Trivial loop based scheduler, which iterates over all blocks in definition order in the graph until no node did any processing */ -template -class Simple : public SchedulerBase { +template +class Simple : public SchedulerBase { std::vector> _job_lists{}; public: explicit Simple(gr::Graph &&graph, std::shared_ptr thread_pool = std::make_shared("simple-scheduler-pool", thread_pool::CPU_BOUND), const profiling::options &profiling_options = {}) - : SchedulerBase(std::forward(graph), thread_pool, profiling_options) {} + : SchedulerBase(std::forward(graph), thread_pool, profiling_options) {} void init() { - SchedulerBase::init(); - [[maybe_unused]] const auto pe = this->_profiler_handler.start_complete_event("scheduler_simple.init"); + SchedulerBase::init(); + [[maybe_unused]] const auto pe = this->_profiler_handler.startCompleteEvent("scheduler_simple.init"); // generate job list if constexpr (executionPolicy == multiThreaded) { const auto n_batches = std::min(static_cast(this->_pool->maxThreads()), this->_graph.blocks().size()); @@ -239,7 +239,7 @@ class Simple : public SchedulerBase { // todo: iterate api for continuous flowgraphs vs ones that become "DONE" at some point void runAndWait() { - [[maybe_unused]] const auto pe = this->_profiler_handler.start_complete_event("scheduler_simple.runAndWait"); + [[maybe_unused]] const auto pe = this->_profiler_handler.startCompleteEvent("scheduler_simple.runAndWait"); start(); this->waitDone(); } @@ -284,21 +284,21 @@ class Simple : public SchedulerBase { * Breadth first traversal scheduler which traverses the graph starting from the source blocks in a breath first fashion * detecting cycles and blocks which can be reached from several source blocks. */ -template -class BreadthFirst : public SchedulerBase { +template +class BreadthFirst : public SchedulerBase { std::vector _blocklist; std::vector> _job_lists{}; public: explicit BreadthFirst(gr::Graph &&graph, std::shared_ptr thread_pool = std::make_shared("breadth-first-pool", thread_pool::CPU_BOUND), - const profiling::options &profiling_options = {}) - : SchedulerBase(std::move(graph), thread_pool, profiling_options) {} + const profiling::options &profiling_options = {}) + : SchedulerBase(std::move(graph), thread_pool, profiling_options) {} void init() { - [[maybe_unused]] const auto pe = this->_profiler_handler.start_complete_event("breadth_first.init"); + [[maybe_unused]] const auto pe = this->_profiler_handler.startCompleteEvent("breadth_first.init"); using block_t = BlockModel *; - SchedulerBase::init(); + SchedulerBase::init(); // calculate adjacency list std::map> _adjacency_list{}; std::vector _source_blocks{}; diff --git a/core/include/gnuradio-4.0/sequence.hpp b/core/include/gnuradio-4.0/Sequence.hpp similarity index 100% rename from core/include/gnuradio-4.0/sequence.hpp rename to core/include/gnuradio-4.0/Sequence.hpp diff --git a/core/include/gnuradio-4.0/wait_strategy.hpp b/core/include/gnuradio-4.0/WaitStrategy.hpp similarity index 99% rename from core/include/gnuradio-4.0/wait_strategy.hpp rename to core/include/gnuradio-4.0/WaitStrategy.hpp index 7f24dd641..0e543ff99 100644 --- a/core/include/gnuradio-4.0/wait_strategy.hpp +++ b/core/include/gnuradio-4.0/WaitStrategy.hpp @@ -1,5 +1,5 @@ -#ifndef GNURADIO_WAIT_STRATEGY_HPP -#define GNURADIO_WAIT_STRATEGY_HPP +#ifndef GNURADIO_WAITSTRATEGY_HPP +#define GNURADIO_WAITSTRATEGY_HPP #include #include @@ -11,7 +11,7 @@ #include #include -#include "sequence.hpp" +#include "Sequence.hpp" namespace gr { // clang-format off @@ -371,4 +371,4 @@ class AtomicMutex { } // namespace gr -#endif // GNURADIO_WAIT_STRATEGY_HPP +#endif // GNURADIO_WAITSTRATEGY_HPP diff --git a/core/include/gnuradio-4.0/thread/thread_pool.hpp b/core/include/gnuradio-4.0/thread/thread_pool.hpp index 1d8575649..4a90504d3 100644 --- a/core/include/gnuradio-4.0/thread/thread_pool.hpp +++ b/core/include/gnuradio-4.0/thread/thread_pool.hpp @@ -20,8 +20,8 @@ #include #include +#include "../WaitStrategy.hpp" #include "thread_affinity.hpp" -#include "../wait_strategy.hpp" namespace gr::thread_pool { namespace detail { @@ -176,9 +176,9 @@ using fixed_string = basic_fixed_string; * https://en.cppreference.com/w/cpp/utility/functional/move_only_function/move_only_function */ class move_only_function { - using FunPtr = std::unique_ptr; - FunPtr _erased_fun = { nullptr, [](void *) {} }; - void (*_call)(void *) = nullptr; + using FunPtr = std::unique_ptr; + FunPtr _erased_fun = { nullptr, [](void *) {} }; + void (*_call)(void *) = nullptr; public: constexpr move_only_function() = default; @@ -732,7 +732,7 @@ class BasicThreadPool { running = false; } else if (timeDiffSinceLastUsed > keepAliveDuration) { // decrease to the minimum of _minThreads in a thread safe way unsigned long nThreads = numThreads(); - while (nThreads > minThreads()) { // compare and swap loop + while (nThreads > minThreads()) { // compare and swap loop if (_numThreads.compare_exchange_weak(nThreads, nThreads - 1, std::memory_order_acq_rel)) { _numThreads.notify_all(); if (nThreads == 1) { // cleanup last thread diff --git a/core/include/meson.build b/core/include/meson.build index 6728affde..43547e8e5 100644 --- a/core/include/meson.build +++ b/core/include/meson.build @@ -2,25 +2,21 @@ graph_dep = declare_dependency(include_directories: '.', dependencies : [fmt_dep, reflcpp_dep, pmt_dep]) header_files = [ - 'vir/detail.h', - 'vir/simd_bit.h', - 'vir/simd_bitset.h', - 'vir/simd_cast.h', - 'vir/simd_float_ops.h', - 'vir/simd_resize.h', - 'vir/simd.h', - 'buffer_skeleton.hpp', - 'buffer.hpp', - 'circular_buffer.hpp', - 'claim_strategy.hpp', + 'BufferSkeleton.hpp', + 'Buffer.hpp', + 'CircularBuffer.hpp', + 'ClaimStrategy.hpp', 'Graph.hpp', 'BlockTraits.hpp', 'Block.hpp', 'PortTraits.hpp', 'Port.hpp', - 'sequence.hpp', + 'Sequence.hpp', + 'settings.hpp', 'typelist.hpp', + 'tag.hpp', + 'transactions.hpp', 'utils.hpp', - 'wait_strategy.hpp' + 'WaitStrategy.hpp' ] install_headers(header_files, subdir : 'graph-prototype', preserve_path: true) \ No newline at end of file diff --git a/core/test/qa_DynamicPort.cpp b/core/test/qa_DynamicPort.cpp index 58c70932a..4586e9352 100644 --- a/core/test/qa_DynamicPort.cpp +++ b/core/test/qa_DynamicPort.cpp @@ -4,7 +4,7 @@ #include -#include +#include #include #include diff --git a/core/test/qa_buffer.cpp b/core/test/qa_buffer.cpp index a53b7008a..d85ebdc2a 100644 --- a/core/test/qa_buffer.cpp +++ b/core/test/qa_buffer.cpp @@ -7,12 +7,12 @@ #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #if defined(__clang__) && __clang_major__ >= 16 // clang 16 does not like ut's default reporter_junit due to some issues with stream buffers and output redirection @@ -68,8 +68,8 @@ const boost::ut::suite BasicConceptsTests = [] { value.publish(1); } } - | std::tuple, gr::circular_buffer, - gr::circular_buffer>{ 2, 2, 2 }; + | std::tuple, gr::CircularBuffer, + gr::CircularBuffer>{ 2, 2, 2 }; }; const boost::ut::suite SequenceTests = [] { @@ -186,7 +186,7 @@ const boost::ut::suite UserApiExamples = [] { "UserApi"_test = [] { using namespace gr; - Buffer auto buffer = circular_buffer(1024); + Buffer auto buffer = CircularBuffer(1024); BufferWriter auto writer = buffer.new_writer(); { // source only write example @@ -205,7 +205,7 @@ const boost::ut::suite UserApiExamples = [] { expect(eq(localReader.available(), std::size_t{ 10 })); expect(eq(buffer.n_readers(), std::size_t{ 1 })); // N.B. circular_buffer<..> specific } - expect(eq(buffer.n_readers(), std::size_t{ 0 })); // reader not in scope release atomic reader index + expect(eq(buffer.n_readers(), std::size_t{ 0 })); // reader not in scope release atomic reader index BufferReader auto reader = buffer.new_reader(); // reader does not know about previous submitted data as it joined only after @@ -249,7 +249,7 @@ const boost::ut::suite CircularBufferTests = [] { "CircularBuffer"_test = [](const Allocator &allocator) { using namespace gr; - Buffer auto buffer = circular_buffer(1024, allocator); + Buffer auto buffer = CircularBuffer(1024, allocator); expect(ge(buffer.size(), 1024u)); BufferWriter auto writer = buffer.new_writer(); @@ -360,7 +360,7 @@ const boost::ut::suite CircularBufferExceptionTests = [] { using namespace boost::ut; "CircularBufferExceptions"_test = [] { using namespace gr; - Buffer auto buffer = circular_buffer(1024); + Buffer auto buffer = CircularBuffer(1024); expect(ge(buffer.size(), 1024u)); BufferWriter auto writer = buffer.new_writer(); @@ -381,7 +381,7 @@ const boost::ut::suite UserDefinedTypeCasting = [] { using namespace boost::ut; "UserDefinedTypeCasting"_test = [] { using namespace gr; - Buffer auto buffer = circular_buffer>(1024); + Buffer auto buffer = CircularBuffer>(1024); expect(ge(buffer.size(), 1024u)); BufferWriter auto writer = buffer.new_writer(); @@ -428,8 +428,8 @@ const boost::ut::suite StreamTagConcept = [] { }; expect(eq(sizeof(buffer_tag), std::size_t{ 64 })) << "tag size"; - Buffer auto buffer = circular_buffer(1024); - Buffer auto tagBuffer = circular_buffer(32); + Buffer auto buffer = CircularBuffer(1024); + Buffer auto tagBuffer = CircularBuffer(32); expect(ge(buffer.size(), 1024u)); expect(ge(tagBuffer.size(), 32u)); @@ -475,7 +475,7 @@ const boost::ut::suite NonPowerTwoTests = [] { using Type = std::vector; constexpr std::size_t typeSize = sizeof(std::vector); expect(not std::has_single_bit(typeSize)) << "type is non-power-of-two"; - Buffer auto buffer = circular_buffer(1024); + Buffer auto buffer = CircularBuffer(1024); expect(ge(buffer.size(), 1024u)); if (gr::has_posix_mmap_interface) { expect(buffer.size() % typeSize == 0u) << "divisible by the type size"; @@ -524,7 +524,7 @@ const boost::ut::suite HistoryBufferTest = [] { using namespace gr; "history_buffer"_test = [](const std::size_t &capacity) { - history_buffer hb(capacity); + HistoryBuffer hb(capacity); expect(eq(hb.capacity(), capacity)); expect(eq(hb.size(), 0u)); @@ -542,7 +542,7 @@ const boost::ut::suite HistoryBufferTest = [] { } | std::vector{ 5, 3, 10 }; "history_buffer - range tests"_test = [] { - history_buffer hb(5); + HistoryBuffer hb(5); hb.push_back_bulk(std::array{ 1, 2, 3 }); hb.push_back_bulk(std::vector{ 4, 5, 6 }); expect(eq(hb.capacity(), 5u)); @@ -576,10 +576,10 @@ const boost::ut::suite HistoryBufferTest = [] { "history_buffer edge cases"_test = [] { fmt::print("\n\ntesting edge cases:\n"); - expect(throws([] { history_buffer(0); })) << "throws for 0 capacity"; + expect(throws([] { HistoryBuffer(0); })) << "throws for 0 capacity"; // Create a history buffer of size 1 - history_buffer hb_one(1); + HistoryBuffer hb_one(1); expect(eq(hb_one.capacity(), 1u)); expect(eq(hb_one.size(), 0u)); hb_one.push_back(41); @@ -592,8 +592,8 @@ const boost::ut::suite HistoryBufferTest = [] { expect(throws([&hb_one] { [[maybe_unused]] auto a = hb_one.at(-2); })) << "throws for index > 0"; // Push more elements than buffer size - history_buffer hb_overflow(5); - auto in = std::vector{ 1, 2, 3, 4, 5, 6 }; + HistoryBuffer hb_overflow(5); + auto in = std::vector{ 1, 2, 3, 4, 5, 6 }; hb_overflow.push_back_bulk(in.begin(), in.end()); expect(eq(hb_overflow[0], 6)); hb_overflow.push_back_bulk(std::vector{ 7, 8, 9 }); @@ -602,7 +602,7 @@ const boost::ut::suite HistoryBufferTest = [] { expect(eq(hb_overflow[0], 12)); // Test with different types, e.g., double - history_buffer hb_double(5); + HistoryBuffer hb_double(5); for (int i = 0; i < 10; ++i) { hb_double.push_back(i * 0.1); } diff --git a/core/test/qa_settings.cpp b/core/test/qa_settings.cpp index 0bbf30ff9..57903ecea 100644 --- a/core/test/qa_settings.cpp +++ b/core/test/qa_settings.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include diff --git a/core/test/qa_tags.cpp b/core/test/qa_tags.cpp index f439ad77d..017c82f22 100644 --- a/core/test/qa_tags.cpp +++ b/core/test/qa_tags.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include #include