diff options
| author | Billy O'Neal <bion@microsoft.com> | 2020-06-26 12:16:17 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-26 12:16:17 -0700 |
| commit | 309f6fc9bcb48a68b692b2f4707b5fea7eaf1c60 (patch) | |
| tree | 7049ce82df81bb90d8d596673044f600207d3b0d /toolsrc/include | |
| parent | 91e798afd899f84654f25e3d7f5beb276c6bd5af (diff) | |
| download | vcpkg-309f6fc9bcb48a68b692b2f4707b5fea7eaf1c60.tar.gz vcpkg-309f6fc9bcb48a68b692b2f4707b5fea7eaf1c60.zip | |
[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.
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/vcpkg/base/system.print.h | 23 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/binarycaching.h | 3 |
2 files changed, 24 insertions, 2 deletions
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();
|
