32 if (m_rx_thread && m_rx_thread->joinable()) {
57 std::shared_ptr<cmd> sp(c);
59 m_queue.push_back(sp);
72 std::shared_ptr<cmd> sp(cmds.front());
74 m_queue.push_back(sp);
88 if (m_rx_thread && m_rx_thread->joinable()) {
95 m_rx_thread.reset(
new std::thread(&HW::cmd_q::rx_run,
this));
119 auto it = m_queue.begin();
121 while (it != m_queue.end()) {
122 std::shared_ptr<cmd>
c = *it;
133 rc = c->issue(m_conn);
159 m_queue.erase(m_queue.begin(), m_queue.end());
185 m_cmdQ =
new cmd_q();
191 m_cmdQ->enqueue(cmd);
197 m_cmdQ->enqueue(cmd);
203 m_cmdQ->enqueue(cmds);
227 return (m_cmdQ->write());
238 return (m_poll_state);
246 std::ostringstream os;
249 <<
"rc:" << item_rc.to_string() <<
" data:" << item_data <<
"]";
257 std::ostringstream os;
260 <<
"rc:" << item_rc.to_string() <<
" data:" << item_data <<
"]";
static void connect()
Blocking Connect to VPP.
static rc_t write()
Write/Execute all commands hitherto enqueued.
Error codes that VPP will return during a HW write.
static const log_level_t DEBUG
A command poll the HW for liveness.
pthread_t thread[MAX_CONNS]
std::string to_string() const
convert to string format for debug purposes
virtual rc_t write()
Write all the commands to HW.
void enable()
Enable the passing of commands to VPP - undoes the disable.
The pipe to VPP into which we write the commands.
cmd_q & operator=(const cmd_q &f)
Copy assignement - only used in UT.
void connect()
Blocking [re]connect call - always eventually succeeds, or the universe expires.
static void init()
Initialise the HW.
static const rc_t OK
The HW write was successfull.
static void enqueue(cmd *f)
Enqueue A command for execution.
void disconnect()
Blocking disconnect.
static const log_level_t ERROR
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
The VPP Object Model (VOM) library.
A representation of a method call to VPP.
void disable()
Disable the passing of commands to VPP.
virtual void connect()
Blocking Connect to VPP - call once at bootup.
virtual void enqueue(cmd *c)
Enqueue a command into the Q.
vapi_error_e dispatch(const Common_req *limit=nullptr)
wait for responses from vpp and assign them to appropriate objects
static bool poll()
Blocking pool of the HW connection.