if (iTimeout == 0 || !m_rcvCondition.Wait(m_mutex, m_bHasData, iTimeout))
return false;
m_inBuffer.Pop(buf);
- m_bHasData = m_inBuffer.Size() > 0;
+ m_bHasData = !m_inBuffer.IsEmpty();
}
if (buf)
struct SyncedBuffer
{
public:
- SyncedBuffer(size_t iMaxSize = 100)
- {
- m_maxSize = iMaxSize;
- }
+ SyncedBuffer(size_t iMaxSize = 100) :
+ m_maxSize(iMaxSize) {}
virtual ~SyncedBuffer(void)
{
- CLockObject lock(m_mutex, true);
Clear();
}
void Clear(void)
{
+ CLockObject lock(m_mutex);
while (!m_buffer.empty())
m_buffer.pop();
}
- size_t Size(void) const { return m_buffer.size(); }
+ size_t Size(void)
+ {
+ CLockObject lock(m_mutex);
+ return m_buffer.size();
+ }
+
+ bool IsEmpty(void)
+ {
+ CLockObject lock(m_mutex);
+ return m_buffer.empty();
+ }
bool Push(_BType entry)
{