From 309f6fc9bcb48a68b692b2f4707b5fea7eaf1c60 Mon Sep 17 00:00:00 2001 From: Billy O'Neal Date: Fri, 26 Jun 2020 12:16:17 -0700 Subject: [vcpkg] Delete unused --purge-tombstones and introduce BufferedPrint class (#12049) * Introduce buffered_print class to manage buffered write patterns like in the ci command. * Remove --purge-tombstones option. * Law of demeter. * Make buffered_print imobile. * buffered_print => BufferedPrint * Fix merge conflict. --- toolsrc/include/vcpkg/base/system.print.h | 23 +++++++++++++++++++++++ toolsrc/include/vcpkg/binarycaching.h | 3 +-- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/system.print.h b/toolsrc/include/vcpkg/base/system.print.h index 890c13667..abe685cf5 100644 --- a/toolsrc/include/vcpkg/base/system.print.h +++ b/toolsrc/include/vcpkg/base/system.print.h @@ -41,4 +41,27 @@ namespace vcpkg::System { ::vcpkg::System::details::print(Strings::concat_or_view(args...)); } + + class BufferedPrint + { + ::std::string stdout_buffer; + static constexpr ::std::size_t buffer_size_target = 2048; + static constexpr ::std::size_t expected_maximum_print = 256; + static constexpr ::std::size_t alloc_size = buffer_size_target + expected_maximum_print; + + public: + BufferedPrint() { stdout_buffer.reserve(alloc_size); } + BufferedPrint(const BufferedPrint&) = delete; + BufferedPrint& operator=(const BufferedPrint&) = delete; + void append(::vcpkg::StringView nextView) + { + stdout_buffer.append(nextView.data(), nextView.size()); + if (stdout_buffer.size() > buffer_size_target) + { + ::vcpkg::System::details::print(stdout_buffer); + stdout_buffer.clear(); + } + } + ~BufferedPrint() { ::vcpkg::System::details::print(stdout_buffer); } + }; } diff --git a/toolsrc/include/vcpkg/binarycaching.h b/toolsrc/include/vcpkg/binarycaching.h index d343d6c42..61af79a3f 100644 --- a/toolsrc/include/vcpkg/binarycaching.h +++ b/toolsrc/include/vcpkg/binarycaching.h @@ -40,8 +40,7 @@ namespace vcpkg /// Requests the result of `try_restore()` without actually downloading the package. Used by CI to determine /// missing packages. virtual RestoreResult precheck(const VcpkgPaths& paths, - const Dependencies::InstallPlanAction& action, - bool purge_tombstones) = 0; + const Dependencies::InstallPlanAction& action) = 0; }; IBinaryProvider& null_binary_provider(); -- cgit v1.2.3