[Lldb-commits] [lldb] [lldb] Update JSONTransport to use MainLoop for reading. (PR #152367)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Sat Aug 9 09:06:54 PDT 2025


================
@@ -83,24 +95,69 @@ class JSONTransport {
     return WriteImpl(message);
   }
 
-  /// Reads the next message from the input stream.
+  /// Registers the transport with the MainLoop.
   template <typename T>
-  llvm::Expected<T> Read(const std::chrono::microseconds &timeout) {
-    llvm::Expected<std::string> message = ReadImpl(timeout);
-    if (!message)
-      return message.takeError();
-    return llvm::json::parse<T>(/*JSON=*/*message);
+  llvm::Expected<ReadHandleUP> RegisterReadObject(MainLoopBase &loop,
+                                                  Callback<T> callback) {
+    Status error;
+    ReadHandleUP handle = loop.RegisterReadObject(
+        m_input,
+        [&](MainLoopBase &loop) {
----------------
ashgti wrote:

Done. I removed the `[&]` usage and copied the values by value.

https://github.com/llvm/llvm-project/pull/152367


More information about the lldb-commits mailing list