From 3020c278d20ad57f174b522affcab497f932fe74 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 12 Jan 2023 20:46:25 -0800 Subject: [PATCH] #276: active: finish up interface with extractor and modify example --- examples/hello_world/hello_world.cc | 2 +- src/vt/messaging/active.h | 47 +++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/examples/hello_world/hello_world.cc b/examples/hello_world/hello_world.cc index 659dc86bda..b8308ee1ea 100644 --- a/examples/hello_world/hello_world.cc +++ b/examples/hello_world/hello_world.cc @@ -66,7 +66,7 @@ int main(int argc, char** argv) { if (this_node == 0) { auto msg = vt::makeMessage(this_node); - vt::theMsg()->broadcastMsg(msg); + vt::theMsg()->broadcastMsg(msg); } vt::finalize(); diff --git a/src/vt/messaging/active.h b/src/vt/messaging/active.h index e7e6f727ec..10bdc4a7e0 100644 --- a/src/vt/messaging/active.h +++ b/src/vt/messaging/active.h @@ -686,6 +686,37 @@ struct ActiveMessenger : runtime::component::PollableComponent TagType tag = no_tag ); + template + struct FunctionTraits; + + template + struct FunctionTraits { + using MsgT = T; + using ReturnType = ReturnT; + }; + + + /** + * \brief Broadcast a message (message type not required). + * + * \note Takes ownership of the supplied message. + * + * \param[in] msg the message to broadcast + * \param[in] deliver_to_sender whether msg should be delivered to sender + * \param[in] tag the tag to put on the message + * + * \return the \c PendingSend for the sent message + */ + template + PendingSendType broadcastMsg( + MsgPtrThief::MsgT> msg, + bool deliver_to_sender = true, + TagType tag = no_tag + ) { + using MsgT = typename FunctionTraits::MsgT; + return broadcastMsg(msg, deliver_to_sender, tag); + } + /** * \brief Send a message. * @@ -704,12 +735,24 @@ struct ActiveMessenger : runtime::component::PollableComponent TagType tag = no_tag ); - template + /** + * \brief Send a message (message type not required). + * + * \note Takes ownership of the supplied message. + * + * \param[in] dest the destination node to send the message to + * \param[in] msg the message to send + * \param[in] tag the tag to put on the message + * + * \return the \c PendingSend for the sent message + */ + template PendingSendType sendMsg( NodeType dest, - MsgPtrThief msg, + MsgPtrThief::MsgT> msg, TagType tag = no_tag ) { + using MsgT = typename FunctionTraits::MsgT; return sendMsg(dest, msg, tag); }