[Lldb-commits] [lldb] [lldb] Support non-blocking reads in JSONRPCTransport (PR #144610)
John Harrison via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 17 15:57:26 PDT 2025
================
@@ -67,19 +67,22 @@ ReadFull(IOObject &descriptor, size_t length,
return data.substr(0, length);
}
-static Expected<std::string>
-ReadUntil(IOObject &descriptor, StringRef delimiter,
- std::optional<std::chrono::microseconds> timeout = std::nullopt) {
- std::string buffer;
- buffer.reserve(delimiter.size() + 1);
- while (!llvm::StringRef(buffer).ends_with(delimiter)) {
+Expected<std::string>
+JSONTransport::ReadUntil(IOObject &descriptor, StringRef delimiter,
+ std::optional<std::chrono::microseconds> timeout) {
+ if (!timeout || *timeout != std::chrono::microseconds::zero()) {
+ m_buffer.clear();
+ m_buffer.reserve(delimiter.size() + 1);
+ }
+
+ while (!llvm::StringRef(m_buffer).ends_with(delimiter)) {
Expected<std::string> next =
- ReadFull(descriptor, buffer.empty() ? delimiter.size() : 1, timeout);
+ ReadFull(descriptor, m_buffer.empty() ? delimiter.size() : 1, timeout);
----------------
ashgti wrote:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/read The win32 _read API for reference.
https://github.com/llvm/llvm-project/pull/144610
More information about the lldb-commits
mailing list