Loading...
Searching...
No Matches
msg_task.hpp
Go to the documentation of this file.
//
// Copyright 2011-2015 Ettus Research LLC
// Copyright 2018 Ettus Research, a National Instruments Company
// Copyright 2019 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
#include <uhd/config.hpp>
#include <uhd/transport/zero_copy.hpp>
#include <uhd/utils/noncopyable.hpp>
#include <stdint.h>
#include <boost/optional/optional.hpp>
#include <cstring>
#include <functional>
#include <memory>
#include <vector>
namespace uhd {
class UHD_API msg_task : uhd::noncopyable
{
public:
typedef std::shared_ptr<msg_task> sptr;
typedef std::vector<uint8_t> msg_payload_t;
typedef std::pair<uint32_t, msg_payload_t> msg_type_t;
typedef std::function<boost::optional<msg_type_t>(void)> task_fcn_type;
/*
* During shutdown message queues for radio control cores might not be available
* anymore. Such stranded messages get pushed into a dump queue. With this function
* radio_ctrl_core can check if one of the messages meant for it got stranded.
*/
virtual msg_payload_t get_msg_from_dump_queue(uint32_t sid) = 0;
UHD_INLINE static std::vector<uint8_t> buff_to_vector(uint8_t* p, size_t n)
{
if (p and n > 0) {
std::vector<uint8_t> v(n);
memcpy(&v.front(), p, n);
return v;
}
return std::vector<uint8_t>();
}
virtual ~msg_task(void) = 0;
static sptr make(const task_fcn_type& task_fcn);
};
} // namespace uhd
uhd::msg_task
Definition msg_task.hpp:23
uhd::msg_task::sptr
std::shared_ptr< msg_task > sptr
Definition msg_task.hpp:25
uhd::msg_task::get_msg_from_dump_queue
virtual msg_payload_t get_msg_from_dump_queue(uint32_t sid)=0
uhd::msg_task::msg_payload_t
std::vector< uint8_t > msg_payload_t
Definition msg_task.hpp:26
uhd::msg_task::msg_type_t
std::pair< uint32_t, msg_payload_t > msg_type_t
Definition msg_task.hpp:27
uhd::msg_task::~msg_task
virtual ~msg_task(void)=0
uhd::msg_task::make
static sptr make(const task_fcn_type &task_fcn)
uhd::msg_task::buff_to_vector
static UHD_INLINE std::vector< uint8_t > buff_to_vector(uint8_t *p, size_t n)
Definition msg_task.hpp:37
uhd::msg_task::task_fcn_type
std::function< boost::optional< msg_type_t >(void)> task_fcn_type
Definition msg_task.hpp:28
UHD_INLINE
#define UHD_INLINE
Definition config.h:65
UHD_API
#define UHD_API
Definition config.h:87
config.hpp
uhd
Definition build_info.hpp:12
uhd::noncopyable
boost::noncopyable noncopyable
Definition noncopyable.hpp:45
noncopyable.hpp
zero_copy.hpp