diff options
Diffstat (limited to 'gruel/src/include')
-rw-r--r-- | gruel/src/include/.gitignore | 2 | ||||
-rw-r--r-- | gruel/src/include/gruel/.gitignore | 4 | ||||
-rw-r--r-- | gruel/src/include/gruel/Makefile.am | 1 | ||||
-rw-r--r-- | gruel/src/include/gruel/msg_accepter.h | 13 | ||||
-rw-r--r-- | gruel/src/include/gruel/msg_accepter_msgq.h | 3 | ||||
-rw-r--r-- | gruel/src/include/gruel/pmt.h | 42 | ||||
-rw-r--r-- | gruel/src/include/gruel/send.h | 49 |
7 files changed, 108 insertions, 6 deletions
diff --git a/gruel/src/include/.gitignore b/gruel/src/include/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gruel/src/include/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gruel/src/include/gruel/.gitignore b/gruel/src/include/gruel/.gitignore new file mode 100644 index 000000000..bbe96391c --- /dev/null +++ b/gruel/src/include/gruel/.gitignore @@ -0,0 +1,4 @@ +/Makefile +/Makefile.in +/inet.h +/pmt_serial_tags.h diff --git a/gruel/src/include/gruel/Makefile.am b/gruel/src/include/gruel/Makefile.am index c38c7fa38..9f50cb619 100644 --- a/gruel/src/include/gruel/Makefile.am +++ b/gruel/src/include/gruel/Makefile.am @@ -35,6 +35,7 @@ gruelinclude_HEADERS = \ pmt_pool.h \ pmt_serial_tags.h \ realtime.h \ + send.h \ sys_pri.h \ thread_body_wrapper.h \ thread_group.h \ diff --git a/gruel/src/include/gruel/msg_accepter.h b/gruel/src/include/gruel/msg_accepter.h index bc287afae..3afd6dde0 100644 --- a/gruel/src/include/gruel/msg_accepter.h +++ b/gruel/src/include/gruel/msg_accepter.h @@ -18,8 +18,8 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef INCLUDED_MSG_ACCEPTER_H -#define INCLUDED_MSG_ACCEPTER_H +#ifndef INCLUDED_GRUEL_MSG_ACCEPTER_H +#define INCLUDED_GRUEL_MSG_ACCEPTER_H #include <gruel/pmt.h> @@ -34,9 +34,16 @@ namespace gruel { msg_accepter() {}; virtual ~msg_accepter(); + /*! + * \brief send \p msg to \p msg_accepter + * + * Sending a message is an asynchronous operation. The \p post + * call will not wait for the message either to arrive at the + * destination or to be received. + */ virtual void post(pmt::pmt_t msg) = 0; }; } /* namespace gruel */ -#endif /* INCLUDED_MSG_ACCEPTER_H */ +#endif /* INCLUDED_GRUEL_MSG_ACCEPTER_H */ diff --git a/gruel/src/include/gruel/msg_accepter_msgq.h b/gruel/src/include/gruel/msg_accepter_msgq.h index b14049d54..bf1762e92 100644 --- a/gruel/src/include/gruel/msg_accepter_msgq.h +++ b/gruel/src/include/gruel/msg_accepter_msgq.h @@ -32,13 +32,14 @@ namespace gruel { */ class msg_accepter_msgq : public msg_accepter { + protected: msg_queue_sptr d_msg_queue; public: msg_accepter_msgq(msg_queue_sptr msgq); ~msg_accepter_msgq(); - void post(pmt::pmt_t msg); + virtual void post(pmt::pmt_t msg); msg_queue_sptr msg_queue() const { return d_msg_queue; } }; diff --git a/gruel/src/include/gruel/pmt.h b/gruel/src/include/gruel/pmt.h index de0998b5e..240359301 100644 --- a/gruel/src/include/gruel/pmt.h +++ b/gruel/src/include/gruel/pmt.h @@ -23,7 +23,7 @@ #ifndef INCLUDED_PMT_H #define INCLUDED_PMT_H -#include <boost/shared_ptr.hpp> +#include <boost/intrusive_ptr.hpp> #include <boost/any.hpp> #include <complex> #include <string> @@ -50,8 +50,10 @@ class pmt_base; * \brief typedef for shared pointer (transparent reference counting). * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm */ -typedef boost::shared_ptr<pmt_base> pmt_t; +typedef boost::intrusive_ptr<pmt_base> pmt_t; +extern void intrusive_ptr_add_ref(pmt_base*); +extern void intrusive_ptr_release(pmt_base*); class pmt_exception : public std::logic_error { @@ -237,6 +239,42 @@ pmt_t pmt_cadddr(pmt_t pair); /* * ------------------------------------------------------------------------ + * Tuples + * + * Store a fixed number of objects. Tuples are not modifiable, and thus + * are excellent for use as messages. Indexing is zero based. + * Access time to an element is O(1). + * ------------------------------------------------------------------------ + */ + +//! Return true if \p x is a tuple, othewise false. +bool pmt_is_tuple(pmt_t x); + +pmt_t pmt_make_tuple(); +pmt_t pmt_make_tuple(const pmt_t &e0); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8); +pmt_t pmt_make_tuple(const pmt_t &e0, const pmt_t &e1, const pmt_t &e2, const pmt_t &e3, const pmt_t &e4, const pmt_t &e5, const pmt_t &e6, const pmt_t &e7, const pmt_t &e8, const pmt_t &e9); + +/*! + * If \p x is a vector or proper list, return a tuple containing the elements of x + */ +pmt_t pmt_to_tuple(const pmt_t &x); + +/*! + * Return the contents of position \p k of \p tuple. + * \p k must be a valid index of \p tuple. + */ +pmt_t pmt_tuple_ref(const pmt_t &tuple, size_t k); + +/* + * ------------------------------------------------------------------------ * Vectors * * These vectors can hold any kind of objects. Indexing is zero based. diff --git a/gruel/src/include/gruel/send.h b/gruel/src/include/gruel/send.h new file mode 100644 index 000000000..292017d45 --- /dev/null +++ b/gruel/src/include/gruel/send.h @@ -0,0 +1,49 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#ifndef INCLUDED_GRUEL_SEND_H +#define INCLUDED_GRUEL_SEND_H + +#include <gruel/msg_accepter.h> + +namespace gruel { + + + /*! + * \brief send \p msg to \p msg_accepter + * + * 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 &acc, pmt::pmt_t msg) + { + return acc.post(msg); + } + + + +} /* namespace gruel */ + + +#endif /* INCLUDED_SEND_H */ |