From 4425cea2297d29f7cb90ac045b39928358cff1e4 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Tue, 18 Aug 2009 21:02:13 -0700 Subject: [PATCH] gruel::send can now send to a pmt. --- gruel/src/include/gruel/msg_passing.h | 33 +++++++++++++++++++++++---- gruel/src/lib/pmt/qa_pmt_prims.cc | 9 ++++++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/gruel/src/include/gruel/msg_passing.h b/gruel/src/include/gruel/msg_passing.h index 61105849..ebbeca81 100644 --- a/gruel/src/include/gruel/msg_passing.h +++ b/gruel/src/include/gruel/msg_passing.h @@ -46,7 +46,27 @@ namespace gruel { static inline pmt::pmt_t send(msg_accepter_sptr accepter, const pmt::pmt_t &msg) { - return accepter->post(msg); + accepter->post(msg); + return msg; + } + + /*! + * \brief send message to msg_accepter + * + * \param accepter is the target of the send. + * \param msg is the message to send. It's usually a pmt tuple. + * + * Sending a message is an asynchronous operation. The \p send + * call will not wait for the message either to arrive at the + * destination or to be received. + * + * \returns msg + */ + static inline pmt::pmt_t + send(msg_accepter *accepter, const pmt::pmt_t &msg) + { + accepter->post(msg); + return msg; } /*! @@ -64,7 +84,8 @@ namespace gruel { static inline pmt::pmt_t send(msg_accepter &accepter, const pmt::pmt_t &msg) { - return accepter.post(msg); + accepter.post(msg); + return msg; } /*! @@ -79,9 +100,11 @@ namespace gruel { * * \returns msg */ - pmt::pmt_t - send(const pmt_t &accepter, const pmt::pmt_t &msg); - + static inline pmt::pmt_t + send(pmt::pmt_t accepter, const pmt::pmt_t &msg) + { + return send(pmt_msg_accepter_ref(accepter), msg); + } } /* namespace gruel */ diff --git a/gruel/src/lib/pmt/qa_pmt_prims.cc b/gruel/src/lib/pmt/qa_pmt_prims.cc index e2d6ec4c..04fdc1a4 100644 --- a/gruel/src/lib/pmt/qa_pmt_prims.cc +++ b/gruel/src/lib/pmt/qa_pmt_prims.cc @@ -22,8 +22,7 @@ #include #include -#include -#include +#include #include #include @@ -479,6 +478,12 @@ qa_pmt_prims::test_msg_accepter() CPPUNIT_ASSERT_THROW(pmt_msg_accepter_ref(sym), pmt_wrong_type); CPPUNIT_ASSERT_THROW(pmt_msg_accepter_ref(p0), pmt_wrong_type); + + // just confirm interfaces on send are OK + gruel::send(ma0.get(), sym); + gruel::send(ma0, sym); + gruel::send(p1, sym); + } // ------------------------------------------------------------------------ -- 2.39.5