.. include:: ../../toolkit-substitutions

.. oe:namespace:: OESystem



.. meta::
   :keywords: OEBoundedBuffer, BoundedBuffer

.. attention::

   |CPPONLY|


.. _OESystem_OEBoundedBuffer:

.. oe:class:: OEBoundedBuffer

   .. oe:api::


      template<class T>
      class OEBoundedBuffer

   First-in-first-out (FIFO) queue that only allows for ``maxsize``
   items to be stored in the buffer, hence, "bounded".  It is not
   inherently thread safe by itself. Use this in conjunction with a
   :ref:`OEProtectedBuffer <OESystem_OEProtectedBuffer>` to make a thread-safe queue.

   .. oe:method:: Constructors

      .. oe:api::

         OEBoundedBuffer(oesize_t maxsize)

      Determines the maximum number of elements this queue can
      hold. The ``maxsize`` parameter should be a power-of-2 to allow
      for a more efficient implementation.

   .. oe:method:: Empty

      .. oe:api::

         bool Empty() const

      Returns whether the queue contains any items.

   .. oe:method:: Full

      .. oe:api::

         bool Full() const

      Returns ``true`` if the queue contains ``maxsize`` items.

   .. oe:method:: Get

      .. oe:api::

         T Get()

      Pops the next item off of the queue.

   .. oe:method:: Peek

      .. oe:api::

         T Peek()

      Returns the item that will be returned by the next call to
      :oe:meth:`OESystem::OEBoundedBuffer::Get`, but does not remove
      it from the queue.

   .. oe:method:: Put

      .. oe:api::

         void Put(T obj)

      Pushes an item into the queue.

   .. oe:method:: Size

      .. oe:api::

         oesize_t Size() const

      Returns the current number of items in the queue.
