52 std::shared_ptr<cmd> sp(c);
54 m_queue.push_back(sp);
67 std::shared_ptr<cmd> sp(cmds.front());
69 m_queue.push_back(sp);
82 m_rx_thread.reset(
new std::thread(&HW::cmd_q::rx_run,
this));
96 if (m_rx_thread && m_rx_thread->joinable()) {
124 auto it = m_queue.begin();
126 while (it != m_queue.end()) {
127 std::shared_ptr<cmd>
c = *it;
138 rc = c->issue(m_conn);
164 m_queue.erase(m_queue.begin(), m_queue.end());
190 m_cmdQ =
new cmd_q();
196 m_cmdQ->enqueue(cmd);
202 m_cmdQ->enqueue(cmd);
208 m_cmdQ->enqueue(cmds);
214 return m_cmdQ->connect();
220 m_cmdQ->disconnect();
238 return (m_cmdQ->write());
249 return (m_poll_state);
256 std::ostringstream os;
259 <<
"rc:" << item_rc.to_string() <<
" data:" << item_data <<
"]";
267 std::ostringstream os;
270 <<
"rc:" << item_rc.to_string() <<
" data:" << item_data <<
"]";
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 bool connect()
Blocking Connect to VPP - call once at bootup.
static bool connect()
Blocking Connect to VPP.
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.
virtual void disconnect()
Disconnect to VPP.
vapi_error_e dispatch(const Common_req *limit=nullptr, u32 time=5)
wait for responses from vpp and assign them to appropriate objects
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.
static void disconnect()
Disconnect to VPP.
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.
int connect()
Blocking [re]connect call - always eventually succeeds, or the universe expires.
virtual void enqueue(cmd *c)
Enqueue a command into the Q.
static bool poll()
Blocking pool of the HW connection.