gruel::send can now send to a pmt.
[debian/gnuradio] / gruel / src / include / gruel / msg_passing.h
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/pmt.h>
29 #include <gruel/msg_accepter.h>
30
31
32 namespace gruel {
33
34   /*!
35    * \brief send message to msg_accepter
36    *
37    * \param accepter is the target of the send.
38    * \param msg is the message to send.  It's usually a pmt tuple.
39    *
40    * Sending a message is an asynchronous operation.  The \p send
41    * call will not wait for the message either to arrive at the
42    * destination or to be received.
43    *
44    * \returns msg
45    */
46   static inline pmt::pmt_t
47   send(msg_accepter_sptr accepter, const pmt::pmt_t &msg)
48   {
49     accepter->post(msg);
50     return msg;
51   }
52
53   /*!
54    * \brief send message to msg_accepter
55    *
56    * \param accepter is the target of the send.
57    * \param msg is the message to send.  It's usually a pmt tuple.
58    *
59    * Sending a message is an asynchronous operation.  The \p send
60    * call will not wait for the message either to arrive at the
61    * destination or to be received.
62    *
63    * \returns msg
64    */
65   static inline pmt::pmt_t
66   send(msg_accepter *accepter, const pmt::pmt_t &msg)
67   {
68     accepter->post(msg);
69     return msg;
70   }
71
72   /*!
73    * \brief send message to msg_accepter
74    *
75    * \param accepter is the target of the send.
76    * \param msg is the message to send.  It's usually a pmt tuple.
77    *
78    * Sending a message is an asynchronous operation.  The \p send
79    * call will not wait for the message either to arrive at the
80    * destination or to be received.
81    *
82    * \returns msg
83    */
84   static inline pmt::pmt_t
85   send(msg_accepter &accepter, const pmt::pmt_t &msg)
86   {
87     accepter.post(msg);
88     return msg;
89   }
90
91   /*!
92    * \brief send message to msg_accepter
93    *
94    * \param accepter is the target of the send.  precond: pmt_is_msg_accepter(accepter)
95    * \param msg is the message to send.  It's usually a pmt tuple.
96    *
97    * Sending a message is an asynchronous operation.  The \p send
98    * call will not wait for the message either to arrive at the
99    * destination or to be received.
100    *
101    * \returns msg
102    */
103   static inline pmt::pmt_t
104   send(pmt::pmt_t accepter, const pmt::pmt_t &msg)
105   {
106     return send(pmt_msg_accepter_ref(accepter), msg);
107   }
108
109 } /* namespace gruel */
110
111 #endif /* INCLUDED_GRUEL_MSG_PASSING_H */