mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Revision:
186:707f6e361f3e
Parent:
184:08ed48f1de7f
Child:
187:0387e8f68319
--- a/platform/CircularBuffer.h	Thu Apr 19 17:12:19 2018 +0100
+++ b/platform/CircularBuffer.h	Fri Jun 22 16:45:37 2018 +0100
@@ -89,7 +89,7 @@
 
     /** Pop the transaction from the buffer
      *
-     * @param data Data to be pushed to the buffer
+     * @param data Data to be popped from the buffer
      * @return True if the buffer is not empty and data contains a transaction, false otherwise
      */
     bool pop(T& data) {
@@ -154,6 +154,22 @@
         core_util_critical_section_exit();
         return elements;
     }
+
+    /** Peek into circular buffer without popping
+     *
+     * @param data Data to be peeked from the buffer
+     * @return True if the buffer is not empty and data contains a transaction, false otherwise
+     */
+    bool peek(T& data) const {
+        bool data_updated = false;
+        core_util_critical_section_enter();
+        if (!empty()) {
+            data = _pool[_tail];
+            data_updated = true;
+        }
+        core_util_critical_section_exit();
+        return data_updated;
+    }
     
 private:
     T _pool[BufferSize];