GNU Radio 3.6.4 C++ API
msg_passing.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2009 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 #ifndef INCLUDED_GRUEL_MSG_PASSING_H
22 #define INCLUDED_GRUEL_MSG_PASSING_H
23 
24 /*!
25  * \brief Include this header to use the message passing features
26  */
27 
28 #include <gruel/api.h>
29 #include <gruel/pmt.h>
30 #include <gruel/msg_accepter.h>
31 
32 
33 namespace gruel {
34 
35  /*!
36  * \brief send message to msg_accepter
37  *
38  * \param accepter is the target of the send.
39  * \param which_port A pmt symbol describing the port by name.
40  * \param msg is the message to send. It's usually a pmt tuple.
41  *
42  * Sending a message is an asynchronous operation. The \p send
43  * call will not wait for the message either to arrive at the
44  * destination or to be received.
45  *
46  * \returns msg
47  */
48  static inline pmt::pmt_t
49  send(msg_accepter_sptr accepter, const pmt::pmt_t &which_port, const pmt::pmt_t &msg)
50  {
51  accepter->post(which_port, msg);
52  return msg;
53  }
54 
55  /*!
56  * \brief send message to msg_accepter
57  *
58  * \param accepter is the target of the send.
59  * \param which_port A pmt symbol describing the port by name.
60  * \param msg is the message to send. It's usually a pmt tuple.
61  *
62  * Sending a message is an asynchronous operation. The \p send
63  * call will not wait for the message either to arrive at the
64  * destination or to be received.
65  *
66  * \returns msg
67  */
68  static inline pmt::pmt_t
69  send(msg_accepter *accepter, const pmt::pmt_t &which_port, const pmt::pmt_t &msg)
70  {
71  accepter->post(which_port, msg);
72  return msg;
73  }
74 
75  /*!
76  * \brief send message to msg_accepter
77  *
78  * \param accepter is the target of the send.
79  * \param which_port A pmt symbol describing the port by name.
80  * \param msg is the message to send. It's usually a pmt tuple.
81  *
82  * Sending a message is an asynchronous operation. The \p send
83  * call will not wait for the message either to arrive at the
84  * destination or to be received.
85  *
86  * \returns msg
87  */
88  static inline pmt::pmt_t
89  send(msg_accepter &accepter, const pmt::pmt_t &which_port, const pmt::pmt_t &msg)
90  {
91  accepter.post(which_port, msg);
92  return msg;
93  }
94 
95  /*!
96  * \brief send message to msg_accepter
97  *
98  * \param accepter is the target of the send. precond: pmt_is_msg_accepter(accepter)
99  * \param which_port A pmt symbol describing the port by name.
100  * \param msg is the message to send. It's usually a pmt tuple.
101  *
102  * Sending a message is an asynchronous operation. The \p send
103  * call will not wait for the message either to arrive at the
104  * destination or to be received.
105  *
106  * \returns msg
107  */
108  static inline pmt::pmt_t
109  send(pmt::pmt_t accepter, const pmt::pmt_t &which_port, const pmt::pmt_t &msg)
110  {
111  return send(pmt_msg_accepter_ref(accepter), which_port, msg);
112  }
113 
114 } /* namespace gruel */
115 
116 #endif /* INCLUDED_GRUEL_MSG_PASSING_H */