[DEBUG] correct fifo interface

This commit is contained in:
Edouard DUPIN 2015-09-07 21:14:56 +02:00
parent d7a3448d77
commit aec415ea7c

View File

@ -48,13 +48,13 @@ namespace etk {
bool wait(MY_TYPE &_data) { bool wait(MY_TYPE &_data) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<std::mutex> lock(m_mutex);
// Check if data is not previously here // Check if data is not previously here
while(0==m_data.size()) { while(m_data.size() == 0) {
m_condition.wait(lock); m_condition.wait(lock);
} }
// End Waiting message : // End Waiting message :
if (0<m_data.size()) { if (m_data.size() > 0) {
// copy element : // copy element :
_data = m_data[0]; std::swap(_data, m_data[0]);
// remove element : // remove element :
m_data.erase(m_data.begin()); m_data.erase(m_data.begin());
return true; return true;
@ -71,15 +71,15 @@ namespace etk {
bool wait(MY_TYPE &_data, uint32_t _timeOutInUs) { bool wait(MY_TYPE &_data, uint32_t _timeOutInUs) {
std::unique_lock<std::mutex> lock(m_mutex); std::unique_lock<std::mutex> lock(m_mutex);
// Check if data is not previously here // Check if data is not previously here
while(0==m_data.size()) { while(m_data.size() == 0) {
if (m_condition.wait_for(lock, std::chrono::microseconds(_timeOutInUs)) == std::cv_status::timeout) { if (m_condition.wait_for(lock, std::chrono::microseconds(_timeOutInUs)) == std::cv_status::timeout) {
return false; return false;
} }
} }
// End Waiting message : // End Waiting message :
if (0<m_data.size()) { if (m_data.size() > 0) {
// copy element : // copy element :
_data = m_data[0]; std::swap(_data, m_data[0]);
// remove element : // remove element :
m_data.erase(0); m_data.erase(0);
return true; return true;