Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++20 compatibility #6697

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
af91b57
Fix implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20
syoliver-se Mar 22, 2020
880549c
Allow to choose C++ version in cmake command line
syoliver-se Mar 22, 2020
4a1df6e
Fix deprecated copy warning in gcc 9
syoliver-se Apr 5, 2020
2756589
Minimal Rebuild is deprecated in visual studio since 2015 and is forb…
syoliver-se Apr 5, 2020
cea96d0
random_shuffle is deprecated in C++14 and removed in C++17
syoliver-se Apr 5, 2020
4e46260
Fix implicit this lambda capture deprecation
syoliver-se Apr 5, 2020
96f7359
Add implicit lambda capture in raw makefile
syoliver-se Apr 6, 2020
5962870
Add MSVC2019 to AppVeyor
syoliver-se Apr 6, 2020
d31e395
Add gcc-9 with c++11 and c++20 to travis
syoliver-se Apr 6, 2020
43eee91
Merge remote-tracking branch 'origin/master' into pr/6648
pdillinger Apr 10, 2020
87f3151
Reduce cmake variants built on each PR
pdillinger Apr 10, 2020
831fb29
Fix whitespace / noeol in CMakeLists.txt
pdillinger Apr 10, 2020
3de7ca9
Tweak so that no configuration change is needed
pdillinger Apr 10, 2020
c9e951e
Unified RandomShuffle
pdillinger Apr 13, 2020
756ea7f
Remove 'this' capture from folly import
pdillinger Apr 14, 2020
1b7b028
Remove an unnecessary capture spec
pdillinger Apr 14, 2020
dda5107
make format
pdillinger Apr 14, 2020
427a33d
Merge remote-tracking branch 'origin/master' into cxx20
pdillinger Apr 14, 2020
882a9d5
Fixup after merge
pdillinger Apr 14, 2020
c19c8ac
Better capture solution for Baton.h
pdillinger Apr 14, 2020
da5b61e
Actually, just use explicit capture
pdillinger Apr 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix implicit this lambda capture deprecation
  • Loading branch information
syoliver-se committed Apr 5, 2020
commit 4e462601e2aadfc49fb08165405689527fa9a7cf
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,12 @@ int main() {
unset(CMAKE_REQUIRED_FLAGS)

if(HAVE_IMPLICIT_THIS_LAMBDA_CAPTURE)
add_definitions(-DROCKSDB_SUPPORT_IMPLICIT_THIS_LAMBDA_CAPTURE)
set(ROCKSDB_THIS_LAMBDA_CAPTURE "=")
else()
set(ROCKSDB_THIS_LAMBDA_CAPTURE "=, this")
endif()
add_definitions(-DROCKSDB_THIS_LAMBDA_CAPTURE=${ROCKSDB_THIS_LAMBDA_CAPTURE})


include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/include)
Expand Down
19 changes: 6 additions & 13 deletions memory/concurrent_arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,8 @@ class ConcurrentArena : public Allocator {

char* Allocate(size_t bytes) override {
return AllocateImpl(bytes, false /*force_arena*/,
#ifdef ROCKSDB_SUPPORT_IMPLICIT_THIS_LAMBDA_CAPTURE
[=]() {
#else
[=, this]() {
#endif
return arena_.Allocate(bytes);
[ROCKSDB_THIS_LAMBDA_CAPTURE]() {
return arena_.Allocate(bytes);
});
}

Expand All @@ -65,13 +61,10 @@ class ConcurrentArena : public Allocator {
(rounded_up % sizeof(void*)) == 0);

return AllocateImpl(rounded_up, huge_page_size != 0 /*force_arena*/,
#ifdef ROCKSDB_SUPPORT_IMPLICIT_THIS_LAMBDA_CAPTURE
[=]() {
#else
[=, this]() {
#endif
return arena_.AllocateAligned(rounded_up, huge_page_size, logger);
});
[ROCKSDB_THIS_LAMBDA_CAPTURE]() {
return arena_.AllocateAligned(rounded_up, huge_page_size, logger);
}
);
}

size_t ApproximateMemoryUsage() const {
Expand Down
10 changes: 7 additions & 3 deletions table/block_based/block_based_table_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -661,13 +661,17 @@ BlockBasedTableBuilder::BlockBasedTableBuilder(
rep_->pc_rep->compress_thread_pool.reserve(
rep_->compression_opts.parallel_threads);
for (uint32_t i = 0; i < rep_->compression_opts.parallel_threads; i++) {
rep_->pc_rep->compress_thread_pool.emplace_back([=] {
rep_->pc_rep->compress_thread_pool.emplace_back([ROCKSDB_THIS_LAMBDA_CAPTURE] {
BGWorkCompression(*(rep_->compression_ctxs[i]),
rep_->verify_ctxs[i].get());
});
}
rep_->pc_rep->write_thread.reset(
new port::Thread([=] { BGWorkWriteRawBlock(); }));
rep_->pc_rep->write_thread.reset(new port::Thread(
[ROCKSDB_THIS_LAMBDA_CAPTURE] {
BGWorkWriteRawBlock();
}
)
);
}
}

Expand Down
12 changes: 2 additions & 10 deletions third-party/folly/folly/synchronization/Baton.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,7 @@ class Baton {
const std::chrono::time_point<Clock, Duration>& deadline,
const WaitOptions& opt) noexcept {

#ifdef ROCKSDB_SUPPORT_IMPLICIT_THIS_LAMBDA_CAPTURE
switch (detail::spin_pause_until(deadline, opt, [=] { return ready(); })) {
#else
switch (detail::spin_pause_until(deadline, opt, [=, this] { return ready(); })) {
#endif
switch (detail::spin_pause_until(deadline, opt, [ROCKSDB_THIS_LAMBDA_CAPTURE] { return ready(); })) {
case detail::spin_result::success:
return true;
case detail::spin_result::timeout:
Expand All @@ -264,11 +260,7 @@ class Baton {
}

if (!MayBlock) {
#ifdef ROCKSDB_SUPPORT_IMPLICIT_THIS_LAMBDA_CAPTURE
switch (detail::spin_yield_until(deadline, [=] { return ready(); })) {
#else
switch (detail::spin_yield_until(deadline, [=, this] { return ready(); })) {
#endif
switch (detail::spin_yield_until(deadline, [ROCKSDB_THIS_LAMBDA_CAPTURE] { return ready(); })) {
case detail::spin_result::success:
return true;
case detail::spin_result::timeout:
Expand Down
18 changes: 6 additions & 12 deletions utilities/blob_db/blob_db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -622,25 +622,19 @@ void BlobDBImpl::MarkUnreferencedBlobFilesObsolete() {
const SequenceNumber obsolete_seq = GetLatestSequenceNumber();

MarkUnreferencedBlobFilesObsoleteImpl(
#ifdef ROCKSDB_SUPPORT_IMPLICIT_THIS_LAMBDA_CAPTURE
[=](const std::shared_ptr<BlobFile>& blob_file) {
#else
[=, this](const std::shared_ptr<BlobFile>& blob_file) {
#endif
[ROCKSDB_THIS_LAMBDA_CAPTURE](const std::shared_ptr<BlobFile>& blob_file) {
WriteLock file_lock(&blob_file->mutex_);
return MarkBlobFileObsoleteIfNeeded(blob_file, obsolete_seq);
});
}
);
}

void BlobDBImpl::MarkUnreferencedBlobFilesObsoleteDuringOpen() {
MarkUnreferencedBlobFilesObsoleteImpl(
#ifdef ROCKSDB_SUPPORT_IMPLICIT_THIS_LAMBDA_CAPTURE
[=](const std::shared_ptr<BlobFile>& blob_file) {
#else
[=, this](const std::shared_ptr<BlobFile>& blob_file) {
#endif
[ROCKSDB_THIS_LAMBDA_CAPTURE](const std::shared_ptr<BlobFile>& blob_file) {
return MarkBlobFileObsoleteIfNeeded(blob_file, /* obsolete_seq */ 0);
});
}
);
}

void BlobDBImpl::CloseRandomAccessLocked(
Expand Down