diff --git a/include/bx/config.h b/include/bx/config.h index 86a8152..92ef7fd 100644 --- a/include/bx/config.h +++ b/include/bx/config.h @@ -16,10 +16,6 @@ # define BX_CONFIG_ALLOCATOR_CRT 1 #endif // BX_CONFIG_ALLOCATOR_CRT -#ifndef BX_CONFIG_SPSCQUEUE_USE_MUTEX -# define BX_CONFIG_SPSCQUEUE_USE_MUTEX 0 -#endif // BX_CONFIG_SPSCQUEUE_USE_MUTEX - #ifndef BX_CONFIG_CRT_FILE_READER_WRITER # define BX_CONFIG_CRT_FILE_READER_WRITER !(BX_PLATFORM_NACL) #endif // BX_CONFIG_CRT_FILE_READER_WRITER diff --git a/include/bx/spscqueue.h b/include/bx/spscqueue.h index 8d0434d..a44ef76 100644 --- a/include/bx/spscqueue.h +++ b/include/bx/spscqueue.h @@ -12,28 +12,26 @@ #include "semaphore.h" #include "uint32_t.h" -#include - namespace bx { // http://drdobbs.com/article/print?articleId=210604448&siteSectionName= template - class SpScUnboundedQueueLf + class SpScUnboundedQueue { - BX_CLASS(SpScUnboundedQueueLf + BX_CLASS(SpScUnboundedQueue , NO_COPY , NO_ASSIGNMENT ); public: - SpScUnboundedQueueLf() + SpScUnboundedQueue() : m_first(new Node(NULL) ) , m_divider(m_first) , m_last(m_first) { } - ~SpScUnboundedQueueLf() + ~SpScUnboundedQueue() { while (NULL != m_first) { @@ -96,67 +94,6 @@ namespace bx Node* m_last; }; -#if BX_CONFIG_SUPPORTS_THREADING - template - class SpScUnboundedQueueMutex - { - BX_CLASS(SpScUnboundedQueueMutex - , NO_COPY - , NO_ASSIGNMENT - ); - - public: - SpScUnboundedQueueMutex() - { - } - - ~SpScUnboundedQueueMutex() - { - BX_CHECK(m_queue.empty(), "Queue is not empty!"); - } - - void push(Ty* _item) - { - bx::LwMutexScope lock(m_mutex); - m_queue.push_back(_item); - } - - Ty* peek() - { - bx::LwMutexScope lock(m_mutex); - if (!m_queue.empty() ) - { - return m_queue.front(); - } - - return NULL; - } - - Ty* pop() - { - bx::LwMutexScope lock(m_mutex); - if (!m_queue.empty() ) - { - Ty* item = m_queue.front(); - m_queue.pop_front(); - return item; - } - - return NULL; - } - - private: - bx::LwMutex m_mutex; - std::list m_queue; - }; -#endif // BX_CONFIG_SUPPORTS_THREADING - -#if BX_CONFIG_SPSCQUEUE_USE_MUTEX && BX_CONFIG_SUPPORTS_THREADING -# define SpScUnboundedQueue SpScUnboundedQueueMutex -#else -# define SpScUnboundedQueue SpScUnboundedQueueLf -#endif // BX_CONFIG_SPSCQUEUE_USE_MUTEX - #if BX_CONFIG_SUPPORTS_THREADING template class SpScBlockingUnboundedQueue