diff options
author | Ciro Nishiguchi <ciro.nishiguchi@ni.com> | 2019-09-11 14:48:50 -0500 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 12:21:31 -0800 |
commit | 650c07cbcb74b88e1a561a85e25035e553e00f14 (patch) | |
tree | 4085d562123f3ea4e20e70a2b326dcfb3b3674da /host/lib/include/uhdlib/transport | |
parent | f3a86a32944ae68047e6f64369e93a6830742601 (diff) | |
download | uhd-650c07cbcb74b88e1a561a85e25035e553e00f14.tar.gz uhd-650c07cbcb74b88e1a561a85e25035e553e00f14.tar.bz2 uhd-650c07cbcb74b88e1a561a85e25035e553e00f14.zip |
transport: Implement an I/O service that uses an offload thread
The offload_io_service executes another I/O service instance within an
offload thread, and provides synchronization mechanisms to communicate
with clients. Frame buffers are passed from the offload thread to the
client and back via single-producer, single-consumer queues.
Diffstat (limited to 'host/lib/include/uhdlib/transport')
-rw-r--r-- | host/lib/include/uhdlib/transport/offload_io_service.hpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/host/lib/include/uhdlib/transport/offload_io_service.hpp b/host/lib/include/uhdlib/transport/offload_io_service.hpp new file mode 100644 index 000000000..a7d9d211d --- /dev/null +++ b/host/lib/include/uhdlib/transport/offload_io_service.hpp @@ -0,0 +1,66 @@ +// +// Copyright 2019 Ettus Research, a National Instruments brand +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#ifndef INCLUDED_UHDLIB_TRANSPORT_OFFLOAD_IO_SERVICE_HPP +#define INCLUDED_UHDLIB_TRANSPORT_OFFLOAD_IO_SERVICE_HPP + +#include <uhdlib/transport/io_service.hpp> + +namespace uhd { namespace transport { + +/*! + * I/O service with offload thread + * + * Note: This I/O service can only be used with transports that allow releasing + * frame buffers out of order, since flow control packets are handled entirely + * within the offload thread. + */ +class offload_io_service : public io_service +{ +public: + enum client_type_t + { + RECV_ONLY, + SEND_ONLY, + BOTH_SEND_AND_RECV + }; + + enum wait_mode_t + { + POLL, + BLOCK + }; + + /*! + * Options for configuring offload I/O service + */ + struct params_t + { + //! Array of CPU numbers to which to affinitize the offload thread. + std::vector<size_t> cpu_affinity_list; + //! The types of client that the I/O service needs to support. + client_type_t client_type = BOTH_SEND_AND_RECV; + //! The thread behavior when waiting for incoming packets If set to + //! BLOCK, the client type must be set to either RECV_ONLY or SEND_ONLY. + wait_mode_t wait_mode = POLL; + }; + + /*! + * Creates an io service that offloads I/O to a worker thread and + * passes configuration parameters to it. + * + * \param io_srv The io service to perform the actual work in the worker + * thread. + * \param params Parameters to pass to the offload I/O service. + * \return A composite I/O service that executes the provided io service + * in its own thread. + */ + static sptr make(io_service::sptr io_srv, const params_t& params); +}; + +}} // namespace uhd::transport + +#endif /* INCLUDED_UHDLIB_TRANSPORT_OFFLOAD_IO_SERVICE_HPP */ |