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
* ince a async event can be recieved before the command
* completes
*/
- m_pending[c.get()] = c;
-
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
+ * barf out without issuing the rest
*/
- m_pending.erase(c.get());
-
- if (rc_t::OK == rc) {
- /*
- * move to the next
- */
- } else {
- /*
- * barf out without issuing the rest
- */
- VOM_LOG(log_level_t::ERROR) << "Failed to execute: "
- << c->to_string();
- break;
- }
+ VOM_LOG(log_level_t::ERROR) << "Failed to execute: " << c->to_string();
+ break;
}
} else {
/*
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 <>