Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9b037f1

Browse files
committed
fixup! fixup! fixup! fixup! [SQUASH] src: fixup lint issues
1 parentc36be6e commit9b037f1

File tree

4 files changed

+48
-20
lines changed

4 files changed

+48
-20
lines changed

‎src/dataqueue/queue.cc

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class DataQueueImpl final : public DataQueue,
177177
tracker->TrackField("entries", entries_);
178178
}
179179

180-
std::unique_ptr<Reader>getReader()override;
180+
std::shared_ptr<Reader>getReader()override;
181181
SET_MEMORY_INFO_NAME(DataQueue);
182182
SET_SELF_SIZE(DataQueueImpl);
183183

@@ -197,7 +197,9 @@ class DataQueueImpl final : public DataQueue,
197197
// DataQueue with which it is associated, and always from the beginning.
198198
// Reads are non-destructive, meaning that the state of the DataQueue
199199
// will not and cannot be changed.
200-
classIdempotentDataQueueReaderfinal : public DataQueue::Reader {
200+
classIdempotentDataQueueReaderfinal
201+
: public DataQueue::Reader,
202+
public std::enable_shared_from_this<DataQueue::Reader> {
201203
public:
202204
IdempotentDataQueueReader(std::shared_ptr<DataQueueImpl> data_queue)
203205
: data_queue_(std::move(data_queue)) {
@@ -216,6 +218,8 @@ class IdempotentDataQueueReader final : public DataQueue::Reader {
216218
DataQueue::Vec* data,
217219
size_t count,
218220
size_t max_count_hint = bob::kMaxCountHint)override {
221+
std::shared_ptr<DataQueue::Reader> self =shared_from_this();
222+
219223
// If ended is true, this reader has already reached the end and cannot
220224
// provide any more data.
221225
if (ended_) {
@@ -360,7 +364,7 @@ class IdempotentDataQueueReader final : public DataQueue::Reader {
360364
private:
361365
std::shared_ptr<DataQueueImpl> data_queue_;
362366
Maybe<uint32_t> current_index_ = Nothing<uint32_t>();
363-
std::unique_ptr<DataQueue::Reader> current_reader_ =nullptr;
367+
std::shared_ptr<DataQueue::Reader> current_reader_ =nullptr;
364368
bool ended_ =false;
365369
bool pull_pending_ =false;
366370
int last_status_ =0;
@@ -370,7 +374,9 @@ class IdempotentDataQueueReader final : public DataQueue::Reader {
370374
// and removes those entries from the queue as they are fully consumed.
371375
// This means that reads are destructive and the state of the DataQueue
372376
// is mutated as the read proceeds.
373-
classNonIdempotentDataQueueReaderfinal : public DataQueue::Reader {
377+
classNonIdempotentDataQueueReaderfinal
378+
: public DataQueue::Reader,
379+
public std::enable_shared_from_this<NonIdempotentDataQueueReader> {
374380
public:
375381
NonIdempotentDataQueueReader(std::shared_ptr<DataQueueImpl> data_queue)
376382
: data_queue_(std::move(data_queue)) {
@@ -390,6 +396,8 @@ class NonIdempotentDataQueueReader final : public DataQueue::Reader {
390396
DataQueue::Vec* data,
391397
size_t count,
392398
size_t max_count_hint = bob::kMaxCountHint)override {
399+
std::shared_ptr<DataQueue::Reader> self =shared_from_this();
400+
393401
// If ended is true, this reader has already reached the end and cannot
394402
// provide any more data.
395403
if (ended_) {
@@ -543,21 +551,21 @@ class NonIdempotentDataQueueReader final : public DataQueue::Reader {
543551

544552
private:
545553
std::shared_ptr<DataQueueImpl> data_queue_;
546-
std::unique_ptr<DataQueue::Reader> current_reader_ =nullptr;
554+
std::shared_ptr<DataQueue::Reader> current_reader_ =nullptr;
547555
bool ended_ =false;
548556
bool pull_pending_ =false;
549557
int last_status_ =0;
550558
};
551559

552-
std::unique_ptr<DataQueue::Reader>DataQueueImpl::getReader() {
560+
std::shared_ptr<DataQueue::Reader>DataQueueImpl::getReader() {
553561
if (isIdempotent()) {
554-
return std::make_unique<IdempotentDataQueueReader>(shared_from_this());
562+
return std::make_shared<IdempotentDataQueueReader>(shared_from_this());
555563
}
556564

557565
if (lockedToReader_)returnnullptr;
558566
lockedToReader_ =true;
559567

560-
return std::make_unique<NonIdempotentDataQueueReader>(shared_from_this());
568+
return std::make_shared<NonIdempotentDataQueueReader>(shared_from_this());
561569
}
562570

563571
// ============================================================================
@@ -755,7 +763,7 @@ class DataQueueEntry : public EntryBase {
755763
DataQueueEntry&operator=(DataQueueEntry&&) =delete;
756764

757765
std::unique_ptr<DataQueue::Reader>getReader()override {
758-
return data_queue_->getReader();
766+
returnstd::make_unique<ReaderImpl>(data_queue_->getReader());
759767
}
760768

761769
std::unique_ptr<Entry>slice(
@@ -794,6 +802,26 @@ class DataQueueEntry : public EntryBase {
794802

795803
private:
796804
std::shared_ptr<DataQueue> data_queue_;
805+
806+
classReaderImpl :publicDataQueue::Reader {
807+
public:
808+
explicitReaderImpl(std::shared_ptr<DataQueue::Reader> inner) : inner_(std::move(inner)) {}
809+
810+
intPull(DataQueue::Reader::Next next,
811+
int options,
812+
DataQueue::Vec* data,
813+
size_t count,
814+
size_t max_count_hint)override {
815+
return inner_->Pull(std::move(next), options, data, count, max_count_hint);
816+
}
817+
818+
SET_NO_MEMORY_INFO()
819+
SET_MEMORY_INFO_NAME(ReaderImpl)
820+
SET_SELF_SIZE(ReaderImpl)
821+
822+
private:
823+
std::shared_ptr<DataQueue::Reader> inner_;
824+
};
797825
};
798826

799827
// ============================================================================

‎src/dataqueue/queue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class DataQueue : public MemoryRetainer {
219219
// any number of readers can be created, all of which are guaranteed
220220
// to provide the same data. Otherwise, only a single reader is
221221
// permitted.
222-
virtual std::unique_ptr<Reader>getReader() = 0;
222+
virtual std::shared_ptr<Reader>getReader() = 0;
223223

224224
// Append a single new entry to the queue. Appending is only allowed
225225
// when isIdempotent() is false. v8::Nothing<bool>() will be returned

‎src/node_blob.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Blob : public BaseObject {
9191
SET_SELF_SIZE(Reader)
9292

9393
private:
94-
std::unique_ptr<DataQueue::Reader> inner_;
94+
std::shared_ptr<DataQueue::Reader> inner_;
9595
BaseObjectPtr<Blob> strong_ptr_;
9696
bool eos_ =false;
9797
};

‎test/cctest/test_dataqueue.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ TEST(DataQueue, IdempotentDataQueue) {
138138
CHECK_EQ(data_queue->size().ToChecked(), len1 + len2);
139139

140140
// We can acquire multiple readers from the data_queue.
141-
std::unique_ptr<DataQueue::Reader> reader1 = data_queue->getReader();
142-
std::unique_ptr<DataQueue::Reader> reader2 = data_queue->getReader();
141+
std::shared_ptr<DataQueue::Reader> reader1 = data_queue->getReader();
142+
std::shared_ptr<DataQueue::Reader> reader2 = data_queue->getReader();
143143

144144
CHECK_NOT_NULL(reader1);
145145
CHECK_NOT_NULL(reader2);
@@ -289,7 +289,7 @@ TEST(DataQueue, IdempotentDataQueue) {
289289
};
290290

291291
// We can read the expected slice data.
292-
std::unique_ptr<DataQueue::Reader> reader3 = slice1->getReader();
292+
std::shared_ptr<DataQueue::Reader> reader3 = slice1->getReader();
293293
testSlice(reader3);
294294

295295
// We can slice correctly across boundaries.
@@ -364,7 +364,7 @@ TEST(DataQueue, IdempotentDataQueue) {
364364
};
365365

366366
// We can read the expected slice data.
367-
std::unique_ptr<DataQueue::Reader> reader4 = slice2->getReader();
367+
std::shared_ptr<DataQueue::Reader> reader4 = slice2->getReader();
368368
testSlice2(reader4);
369369
}
370370

@@ -426,8 +426,8 @@ TEST(DataQueue, NonIdempotentDataQueue) {
426426
CHECK_NULL(slice1);
427427

428428
// We can acquire only a single reader for a non-idempotent data queue
429-
std::unique_ptr<DataQueue::Reader> reader1 = data_queue->getReader();
430-
std::unique_ptr<DataQueue::Reader> reader2 = data_queue->getReader();
429+
std::shared_ptr<DataQueue::Reader> reader1 = data_queue->getReader();
430+
std::shared_ptr<DataQueue::Reader> reader2 = data_queue->getReader();
431431

432432
CHECK_NOT_NULL(reader1);
433433
CHECK_NULL(reader2);
@@ -499,7 +499,7 @@ TEST(DataQueue, NonIdempotentDataQueue) {
499499
testRead(reader1);
500500

501501
// We still cannot acquire another reader.
502-
std::unique_ptr<DataQueue::Reader> reader3 = data_queue->getReader();
502+
std::shared_ptr<DataQueue::Reader> reader3 = data_queue->getReader();
503503
CHECK_NULL(reader3);
504504

505505
CHECK_NOT_NULL(data_queue);
@@ -555,7 +555,7 @@ TEST(DataQueue, DataQueueEntry) {
555555
// Our original data queue should have a use count of 2.
556556
CHECK_EQ(data_queue.use_count(),2);
557557

558-
std::unique_ptr<DataQueue::Reader> reader = data_queue2->getReader();
558+
std::shared_ptr<DataQueue::Reader> reader = data_queue2->getReader();
559559

560560
bool pullIsPending =true;
561561

@@ -584,7 +584,7 @@ TEST(DataQueue, DataQueueEntry) {
584584
// even though we have already consumed the non-idempotent data queue that
585585
// contained it.
586586

587-
std::unique_ptr<DataQueue::Reader> reader2 = data_queue->getReader();
587+
std::shared_ptr<DataQueue::Reader> reader2 = data_queue->getReader();
588588
CHECK_NOT_NULL(reader2);
589589

590590
pullIsPending =true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp