/** ******************************************************************************* * @file etk/Mutex.h * @brief Ewol Tool Kit : basic mutex system (header) * @author Edouard DUPIN * @date 15/08/2012 * @par Project * Ewol TK * * @par Copyright * Copyright 2011 Edouard DUPIN, all right reserved * * This software is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. * * Licence summary : * You can modify and redistribute the sources code and binaries. * You can send me the bug-fix * * Term of the licence in in the file licence.txt. * ******************************************************************************* */ #ifndef __ETK_MESSAGE_FIFO_H__ #define __ETK_MESSAGE_FIFO_H__ #include #include #include namespace etk { template class MessageFifo { private : etk::Mutex m_mutex; etk::Semaphore m_semaphore; etk::Vector m_data; public : MessageFifo(void) { // nothing to do ... }; ~MessageFifo(void) { // nothing to do ... }; bool Wait(MY_TYPE &data) { m_mutex.Lock(); // Check if data is not previously here while(0==m_data.Size()) { m_mutex.UnLock(); m_semaphore.Wait(); m_mutex.Lock(); } // End Waiting message : if (0