* http://www.pulse-eight.net/
*/
-#include "threads.h"
+#include "../platform/threads.h"
#include <queue>
-template<typename _BType>
- struct CecBuffer
- {
- public:
- CecBuffer(int iMaxSize = 100) {}
- virtual ~CecBuffer(void) {}
-
- bool Push(_BType entry)
+namespace CEC
+{
+ template<typename _BType>
+ struct CecBuffer
{
- CLockObject lock(&m_mutex);
- if (m_buffer.size() == m_maxSize)
- return false;
+ public:
+ CecBuffer(int iMaxSize = 100)
+ {
+ m_maxSize = iMaxSize;
+ }
+ virtual ~CecBuffer(void) {}
- m_buffer.push(entry);
- return true;
- }
+ int Size(void) const { return m_buffer.size(); }
- bool Pop(_BType &entry)
- {
- bool bReturn(false);
- CLockObject lock(&m_mutex);
- if (m_buffer.size() > 0)
+ bool Push(_BType entry)
+ {
+ CLockObject lock(&m_mutex);
+ if (m_buffer.size() == m_maxSize)
+ return false;
+
+ m_buffer.push(entry);
+ return true;
+ }
+
+ bool Pop(_BType &entry)
{
- entry = m_buffer.front();
- m_buffer.pop();
- bReturn = true;
+ bool bReturn(false);
+ CLockObject lock(&m_mutex);
+ if (m_buffer.size() > 0)
+ {
+ entry = m_buffer.front();
+ m_buffer.pop();
+ bReturn = true;
+ }
+ return bReturn;
}
- return bReturn;
- }
- private:
- int m_maxSize;
- std::queue<_BType> m_buffer;
- CMutex m_mutex;
- };
+ private:
+ int m_maxSize;
+ std::queue<_BType> m_buffer;
+ CMutex m_mutex;
+ };
+};