Skip to content

Commit 707e810

Browse files
authored
Ignore future return in the destructor. (#12092)
1 parent a36d291 commit 707e810

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

src/data/sparse_page_source.h

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2014-2024, XGBoost Contributors
2+
* Copyright 2014-2026, XGBoost Contributors
33
* \file sparse_page_source.h
44
*/
55
#ifndef XGBOOST_DATA_SPARSE_PAGE_SOURCE_H_
@@ -58,9 +58,7 @@ struct Cache {
5858
return name + format;
5959
}
6060

61-
[[nodiscard]] std::string ShardName() const {
62-
return ShardName(this->name, this->format);
63-
}
61+
[[nodiscard]] std::string ShardName() const { return ShardName(this->name, this->format); }
6462
[[nodiscard]] bool OnHost() const { return on_host; }
6563
/**
6664
* @brief Record a page with size of n_bytes.
@@ -132,9 +130,7 @@ class TryLockGuard {
132130
explicit TryLockGuard(std::mutex& lock) : lock_{lock} { // NOLINT
133131
CHECK(lock_.try_lock()) << "Multiple threads attempting to use Sparse DMatrix.";
134132
}
135-
~TryLockGuard() {
136-
lock_.unlock();
137-
}
133+
~TryLockGuard() { lock_.unlock(); }
138134
};
139135

140136
// Similar to `dmlc::OMPException`, but doesn't need the threads to be joined before rethrow
@@ -262,7 +258,7 @@ class SparsePageSourceImpl : public BatchIteratorImpl<S>, public FormatStreamPol
262258
// Workers for fetching data from external memory.
263259
common::ThreadPool workers_;
264260

265-
bool at_end_ {false};
261+
bool at_end_{false};
266262
float missing_;
267263
std::int32_t nthreads_;
268264
bst_feature_t n_features_;
@@ -382,13 +378,13 @@ class SparsePageSourceImpl : public BatchIteratorImpl<S>, public FormatStreamPol
382378
monitor_.Init(typeid(S).name()); // not pretty, but works for basic profiling
383379
}
384380

385-
SparsePageSourceImpl(SparsePageSourceImpl const &that) = delete;
381+
SparsePageSourceImpl(SparsePageSourceImpl const& that) = delete;
386382

387383
~SparsePageSourceImpl() override {
388384
// Don't orphan the threads.
389385
for (auto& fu : *ring_) {
390386
if (fu.valid()) {
391-
fu.get();
387+
[[maybe_unused]] auto _ = fu.get();
392388
}
393389
}
394390
}
@@ -400,13 +396,9 @@ class SparsePageSourceImpl : public BatchIteratorImpl<S>, public FormatStreamPol
400396
return *page_;
401397
}
402398

403-
[[nodiscard]] std::shared_ptr<S const> Page() const override {
404-
return page_;
405-
}
399+
[[nodiscard]] std::shared_ptr<S const> Page() const override { return page_; }
406400

407-
[[nodiscard]] bool AtEnd() const override {
408-
return at_end_;
409-
}
401+
[[nodiscard]] bool AtEnd() const override { return at_end_; }
410402
// Call this at the last iteration (it == n_batches).
411403
virtual void EndIter() {
412404
this->cache_info_->Commit();
@@ -588,7 +580,7 @@ class CSCPageSource : public PageSourceIncMixIn<CSCPage> {
588580
protected:
589581
void Fetch() final {
590582
if (!this->ReadCache()) {
591-
auto const &csr = source_->Page();
583+
auto const& csr = source_->Page();
592584
this->page_.reset(new CSCPage{});
593585
// we might be able to optimize this by merging transpose and pushcsc
594586
this->page_->PushCSC(csr->GetTranspose(n_features_, nthreads_));
@@ -610,7 +602,7 @@ class SortedCSCPageSource : public PageSourceIncMixIn<SortedCSCPage> {
610602
protected:
611603
void Fetch() final {
612604
if (!this->ReadCache()) {
613-
auto const &csr = this->source_->Page();
605+
auto const& csr = this->source_->Page();
614606
this->page_.reset(new SortedCSCPage{});
615607
// we might be able to optimize this by merging transpose and pushcsc
616608
this->page_->PushCSC(csr->GetTranspose(n_features_, nthreads_));
@@ -623,9 +615,8 @@ class SortedCSCPageSource : public PageSourceIncMixIn<SortedCSCPage> {
623615
}
624616

625617
public:
626-
SortedCSCPageSource(float missing, int nthreads, bst_feature_t n_features,
627-
uint32_t n_batches, std::shared_ptr<Cache> cache,
628-
std::shared_ptr<SparsePageSource> source)
618+
SortedCSCPageSource(float missing, int nthreads, bst_feature_t n_features, uint32_t n_batches,
619+
std::shared_ptr<Cache> cache, std::shared_ptr<SparsePageSource> source)
629620
: PageSourceIncMixIn(missing, nthreads, n_features, n_batches, cache, true) {
630621
this->source_ = source;
631622
this->Fetch();

0 commit comments

Comments
 (0)