Created
February 15, 2024 11:15
-
-
Save frankosterfeld/67cab23ec3c4e282500e8955e4f42500 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 57ed3a7faf81fd79f33d304343070acd6a2c9dcc | |
Author: Frank Osterfeld <frank.osterfeld@kdab.com> | |
Date: Thu Feb 15 12:13:45 2024 +0100 | |
test | |
diff --git a/core/include/gnuradio-4.0/CircularBuffer.hpp b/core/include/gnuradio-4.0/CircularBuffer.hpp | |
index 99913ae..36055b0 100644 | |
--- a/core/include/gnuradio-4.0/CircularBuffer.hpp | |
+++ b/core/include/gnuradio-4.0/CircularBuffer.hpp | |
@@ -363,7 +363,7 @@ class CircularBuffer | |
std::copy(&data[_index], &data[_index + nFirstHalf], &data[_index + size]); | |
std::copy(&data[size], &data[size + nSecondHalf], &data[0]); | |
} | |
- _parent->_claim_strategy->publish(_offset + static_cast<signed_index_type>(n_produced)); | |
+ _parent->_claim_strategy->publish(_offset, n_produced); | |
_n_slots_to_claim -= n_produced; | |
_published_data = true; | |
} | |
@@ -454,7 +454,7 @@ class CircularBuffer | |
std::copy(&data[index], &data[index + nFirstHalf], &data[index+ _size]); | |
std::copy(&data[_size], &data[_size + nSecondHalf], &data[0]); | |
} | |
- _claim_strategy->publish(publishSequence); // points at first non-writable index | |
+ _claim_strategy->publish(publishSequence - static_cast<signed_index_type>(n_slots_to_claim), n_slots_to_claim); | |
} catch (const std::exception&) { | |
throw; | |
} catch (...) { | |
@@ -605,9 +605,11 @@ class CircularBuffer | |
template <bool strict_check = true> | |
[[nodiscard]] constexpr auto get(const std::size_t nRequested = 0UZ) const noexcept -> ConsumableInputRange { | |
- std::size_t n = nRequested > 0 ? nRequested : available(); | |
+ std::size_t n; | |
if constexpr (strict_check) { | |
n = nRequested > 0 ? std::min(nRequested, available()) : available(); | |
+ } else { | |
+ n = nRequested > 0 ? nRequested : available(); | |
} | |
std::atomic_store_explicit(&_isRangeConsumed, false, std::memory_order_release); | |
_isRangeConsumed.notify_all(); | |
diff --git a/core/include/gnuradio-4.0/ClaimStrategy.hpp b/core/include/gnuradio-4.0/ClaimStrategy.hpp | |
index 433afbc..75d07ed 100644 | |
--- a/core/include/gnuradio-4.0/ClaimStrategy.hpp | |
+++ b/core/include/gnuradio-4.0/ClaimStrategy.hpp | |
@@ -29,7 +29,7 @@ concept ClaimStrategy = requires(T /*const*/ t, const std::vector<std::shared_pt | |
{ t.next(dependents, n_slots_to_claim) } -> std::same_as<std::make_signed_t<std::size_t>>; | |
{ t.tryNext(dependents, n_slots_to_claim) } -> std::same_as<std::make_signed_t<std::size_t>>; | |
{ t.getRemainingCapacity(dependents) } -> std::same_as<std::make_signed_t<std::size_t>>; | |
- { t.publish(sequence) } -> std::same_as<void>; | |
+ { t.publish(sequence, n_slots_to_claim) } -> std::same_as<void>; | |
{ t.isAvailable(sequence) } -> std::same_as<bool>; | |
{ t.getHighestPublishedSequence(sequence, availableSequence) } -> std::same_as<std::make_signed_t<std::size_t>>; | |
}; | |
@@ -108,7 +108,8 @@ public: | |
return static_cast<signed_index_type>(_size) - (produced - consumed); | |
} | |
- void publish(signed_index_type sequence) { | |
+ void publish(signed_index_type sequence, std::size_t n_slots_to_claim) { | |
+ sequence += static_cast<signed_index_type>(n_slots_to_claim); | |
_cursor.setValue(sequence); | |
_nextValue = sequence; | |
if constexpr (hasSignalAllWhenBlocking<WAIT_STRATEGY>) { | |
@@ -277,8 +278,10 @@ public: | |
return static_cast<signed_index_type>(_size) - (produced - consumed); | |
} | |
- void publish(signed_index_type sequence) { | |
- setAvailable(sequence); | |
+ void publish(signed_index_type sequence, std::size_t n_slots_to_claim) { | |
+ for (std::size_t i = 0; i < n_slots_to_claim; i++) { | |
+ setAvailable(sequence + static_cast<signed_index_type>(i) + 1); | |
+ } | |
if constexpr (hasSignalAllWhenBlocking<WAIT_STRATEGY>) { | |
_waitStrategy.signalAllWhenBlocking(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment