mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
quic: further implementation details
PR-URL: https://github.com/nodejs/node/pull/48244 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
This commit is contained in:
1 parent
ab93a35a52
commit
fc102f2180
7 files changed
+1230
-39
No files matched your search
@@ -162,6 +162,27 @@ class DataQueueImpl final : public DataQueue,
|
||||
"entries", entries_, "std::vector<std::unique_ptr<Entry>>");
|
||||
}
|
||||
|
||||
void addBackpressureListener(BackpressureListener* listener) override {
|
||||
if (idempotent_) return;
|
||||
DCHECK_NOT_NULL(listener);
|
||||
backpressure_listeners_.insert(listener);
|
||||
}
|
||||
|
||||
void removeBackpressureListener(BackpressureListener* listener) override {
|
||||
if (idempotent_) return;
|
||||
DCHECK_NOT_NULL(listener);
|
||||
backpressure_listeners_.erase(listener);
|
||||
}
|
||||
|
||||
void NotifyBackpressure(size_t amount) {
|
||||
if (idempotent_) return;
|
||||
for (auto& listener : backpressure_listeners_) listener->EntryRead(amount);
|
||||
}
|
||||
|
||||
bool HasBackpressureListeners() const noexcept {
|
||||
return !backpressure_listeners_.empty();
|
||||
}
|
||||
|
||||
std::shared_ptr<Reader> get_reader() override;
|
||||
SET_MEMORY_INFO_NAME(DataQueue)
|
||||
SET_SELF_SIZE(DataQueueImpl)
|
||||
@@ -173,6 +194,8 @@ class DataQueueImpl final : public DataQueue,
|
||||
std::optional<uint64_t> capped_size_ = std::nullopt;
|
||||
bool locked_to_reader_ = false;
|
||||
|
||||
std::unordered_set<BackpressureListener*> backpressure_listeners_;
|
||||
|
||||
friend class DataQueue;
|
||||
friend class IdempotentDataQueueReader;
|
||||
friend class NonIdempotentDataQueueReader;
|
||||
@@ -433,6 +456,17 @@ class NonIdempotentDataQueueReader final
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is a backpressure listener, lets report on how much data
|
||||
// was actually read.
|
||||
if (data_queue_->HasBackpressureListeners()) {
|
||||
// How much did we actually read?
|
||||
size_t read = 0;
|
||||
for (uint64_t n = 0; n < count; n++) {
|
||||
read += vecs[n].len;
|
||||
}
|
||||
data_queue_->NotifyBackpressure(read);
|
||||
}
|
||||
|
||||
// Now that we have updated this readers state, we can forward
|
||||
// everything on to the outer next.
|
||||
std::move(next)(status, vecs, count, std::move(done));
|
||||
|
||||
Reference in new issue
Block a user