From d8d24b75095261688ad8e51cab0a286827370fbc Mon Sep 17 00:00:00 2001 From: "EXPROGROUP\\john.wellbelove" Date: Fri, 2 Mar 2018 10:00:58 +0000 Subject: [PATCH] Experimental spsc queue --- src/experimental/atomic.h | 56 ++++++++++++++++++++++++++++++++++ src/experimental/spsc_queue.h | 57 +++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 src/experimental/atomic.h create mode 100644 src/experimental/spsc_queue.h diff --git a/src/experimental/atomic.h b/src/experimental/atomic.h new file mode 100644 index 00000000..48669852 --- /dev/null +++ b/src/experimental/atomic.h @@ -0,0 +1,56 @@ +/****************************************************************************** +The MIT License(MIT) + +Embedded Template Library. +https://github.com/ETLCPP/etl +https://www.etlcpp.com + +Copyright(c) 2017 jwellbelove + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files(the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +******************************************************************************/ + +#ifndef __ETL_ATOMIC__ +#define __ETL_ATOMIC__ + +#include "platform.h" + +#if ETL_ATOMIC_SUPPORTED == 1 + #include + + namespace etl + { + typedef std::atomic atomic_uint32_t; + } + #define ETL_CPP11_ATOMIC_AVAILABLE 1 +#elif defined(ETL_COMPILER_ARM) + #include "atomic/atomic_arm.h" + #define ETL_ETL_ATOMIC_AVAILABLE 1 +#elif defined(ETL_COMPILER_GCC) + #include "atomic/atomic_gcc.h" + #define ETL_ATOMIC_AVAILABLE 1 +#elif defined(ETL_COMPILER_MSVC) + #include "atomic/atomic_windows.h" + #define ETL_ATOMIC_AVAILABLE 1 +#else + #warning NO ATOMIC SUPPORT DEFINED! + #define ETL_ATOMIC_AVAILABLE 0 +#endif + +#endif diff --git a/src/experimental/spsc_queue.h b/src/experimental/spsc_queue.h new file mode 100644 index 00000000..253d5db1 --- /dev/null +++ b/src/experimental/spsc_queue.h @@ -0,0 +1,57 @@ + +#include "platform.h" + +#include "atomic.h" + +struct spsc_queue_implementation +{ + enum + { + UNKNOWN, + STD_ATOMIC, + ETL_ATOMIC, + CMSIS_RTOS2, + FREERTOS, + GCC, + WIN32 + }; +}; + +template +class ispsc_queue; + +template +class spsc_queue : public ispsc_queue; + +#if ETL_ATOMIC_AVAILABLE +template +class ispsc_queue +{ + +}; + +template +class spsc_queue + : public ispsc_queue +{ + +}; +#endif + +#if ETL_OPERATING_SYSTEM == ETL_CMSIS_RTOS2 +template +class spsc_queue + : public ispsc_queue +{ + +}; +#endif + +#if ETL_OPERATING_SYSTEM == ETL_FREERTOS +template +class spsc_queue + : public ispsc_queue +{ + +}; +#endif