HW::cmd_q::~cmd_q()
{
- m_connected = false;
-
- if (m_rx_thread && m_rx_thread->joinable()) {
- m_rx_thread->join();
- }
}
HW::cmd_q&
}
}
-void
-HW::cmd_q::dequeue(cmd* c)
+bool
+HW::cmd_q::connect()
{
- c->retire(m_conn);
- m_pending.erase(c);
-}
+ if (m_connected)
+ return m_connected;
-void
-HW::cmd_q::dequeue(std::shared_ptr<cmd> c)
-{
- c->retire(m_conn);
- m_pending.erase(c.get());
+ if (0 == m_conn.connect()) {
+ m_connected = true;
+ m_rx_thread.reset(new std::thread(&HW::cmd_q::rx_run, this));
+ }
+ return (m_connected);
}
void
-HW::cmd_q::connect()
+HW::cmd_q::disconnect()
{
- if (m_connected) {
- m_conn.disconnect();
- }
+
+ if (!m_connected)
+ return;
m_connected = false;
m_rx_thread->join();
}
- m_conn.connect();
-
- m_connected = true;
- m_rx_thread.reset(new std::thread(&HW::cmd_q::rx_run, this));
+ m_conn.disconnect();
}
void
rc_t rc = rc_t::OK;
/*
- * The queue is enabled, Execute each command in the queue.
- * If one execution fails, abort the rest
- */
+ * The queue is enabled, Execute each command in the queue.
+ * If one execution fails, abort the rest
+ */
auto it = m_queue.begin();
while (it != m_queue.end()) {
if (m_enabled) {
/*
- * before we issue the command we must move it to the pending
- * store
- * ince a async event can be recieved before the command
- * completes
- */
- m_pending[c.get()] = c;
-
+ * before we issue the command we must move it to the pending
+ * store
+ * ince a async event can be recieved before the command
+ * completes
+ */
rc = c->issue(m_conn);
- if (rc_t::INPROGRESS == rc) {
+ if (rc_t::OK == rc) {
/*
- * this command completes asynchronously
- * leave the command in the pending store
- */
+ * move to the next
+ */
} else {
/*
- * the command completed, remove from the pending store
- */
- m_pending.erase(c.get());
-
- if (rc_t::OK == rc) {
- /*
- * move to the next
- */
- } else {
- /*
- * barf out without issuing the rest
- */
- break;
- }
+ * barf out without issuing the rest
+ */
+ VOM_LOG(log_level_t::ERROR) << "Failed to execute: " << c->to_string();
+ break;
}
} else {
/*
- * The HW is disabled, so set each command as succeeded
- */
+ * The HW is disabled, so set each command as succeeded
+ */
c->succeeded();
}
}
/*
- * erase all objects in the queue
- */
+ * erase all objects in the queue
+ */
m_queue.erase(m_queue.begin(), m_queue.end());
return (rc);
m_cmdQ->enqueue(cmds);
}
-void
-HW::dequeue(cmd* cmd)
-{
- m_cmdQ->dequeue(cmd);
-}
-
-void
-HW::dequeue(std::shared_ptr<cmd> cmd)
+bool
+HW::connect()
{
- m_cmdQ->dequeue(cmd);
+ return m_cmdQ->connect();
}
void
-HW::connect()
+HW::disconnect()
{
- m_cmdQ->connect();
+ m_cmdQ->disconnect();
}
void
HW::write();
return (m_poll_state);
- return (true);
}
template <>