From 60dfafcb5f398f81ef17f78c0ba7e4c1891c7085 Mon Sep 17 00:00:00 2001
From: Tyler Neely <t@jujit.su>
Date: Thu, 11 Aug 2022 17:02:21 +0000
Subject: [PATCH] Add ThriftHandle::DeliverMessage method

---
 src/io/thrift/thrift_handle.hpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/io/thrift/thrift_handle.hpp b/src/io/thrift/thrift_handle.hpp
index ec6502c5d..a617feb19 100644
--- a/src/io/thrift/thrift_handle.hpp
+++ b/src/io/thrift/thrift_handle.hpp
@@ -35,6 +35,18 @@ class ThriftHandle {
   std::map<Address, void> clients_;
 
  public:
+  template <Message M>
+  void DeliverMessage(Address from_address, RequestId request_id, M &&message) {
+    {
+      std::unique_lock<std::mutex> lock(mu_);
+      std::any message_any(std::move(message));
+      OpaqueMessage om{.from_address = from_address, .request_id = request_id, .message = std::move(message_any)};
+      can_receive_.emplace_back(std::move(om));
+    }  // lock dropped
+
+    cv_.notify_all();
+  }
+
   template <Message Request, Message Response>
   void SubmitRequest(Address to_address, Address from_address, RequestId request_id, Request &&request,
                      Duration timeout, ResponsePromise<Response> &&promise) {