[libc-commits] [PATCH] D149788: [libc][rpc] Simplify mailbox state tracking

Jon Chesterfield via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed May 3 15:18:55 PDT 2023


JonChesterfield added inline comments.


================
Comment at: libc/src/__support/OSUtil/gpu/io.cpp:18
 void write_to_stderr(cpp::string_view msg) {
-  rpc::Port port = rpc::client.open(rpc::PRINT_TO_STDERR);
+  rpc::Client::Port port = rpc::client.open(rpc::PRINT_TO_STDERR);
   port.send_n(msg.data(), msg.size());
----------------
jhuber6 wrote:
> I guess since this is a templated type now we can't just have a generic port? Also what happened to the one in `Server.h`.
Server.h used auto. I don't know what you have in mind for "generic port", but any user of this has a Client or Server instance available. Moving Port to a member of Process would remove some line noise, as would writing more of the methods on port in the struct,


================
Comment at: libc/src/__support/RPC/rpc.h:96
+  /// Determines if this process owns the buffer for a send.
   LIBC_INLINE static bool can_send_data(uint32_t in, uint32_t out) {
+    return in == out;
----------------
jhuber6 wrote:
> Can probably just call this `can_use_buffer` and get rid of the other one. I think keeping `send` and `recv` separate is more readable however.
I favour in != out at the call sites but didn't want to disturb them as part of this review. D149788, D149793 are separate to similarly avoid noise in the diff.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149788/new/

https://reviews.llvm.org/D149788



More information about the libc-commits mailing list