X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fplatform%2Futil%2Fbuffer.h;h=56ffd6450225384359ce1cb4a159d784d3fb624e;hb=0eb7639ed29e68a004e3eee32d53395d98252657;hp=1c12e86dd05b6ec961f5521f1252ddec0712be58;hpb=ba65909d0a9c43a1bac71c6182c53f202285cec5;p=deb_libcec.git diff --git a/src/lib/platform/util/buffer.h b/src/lib/platform/util/buffer.h index 1c12e86..56ffd64 100644 --- a/src/lib/platform/util/buffer.h +++ b/src/lib/platform/util/buffer.h @@ -2,7 +2,7 @@ /* * This file is part of the libCEC(R) library. * - * libCEC(R) is Copyright (C) 2011 Pulse-Eight Limited. All rights reserved. + * libCEC(R) is Copyright (C) 2011-2012 Pulse-Eight Limited. All rights reserved. * libCEC(R) is an original work, containing original code. * * libCEC(R) is a trademark of Pulse-Eight Limited. @@ -40,24 +40,32 @@ namespace PLATFORM 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) {