diff options
Diffstat (limited to '3rdparty/bx/include/bx/mpscqueue.h')
-rw-r--r-- | 3rdparty/bx/include/bx/mpscqueue.h | 82 |
1 files changed, 35 insertions, 47 deletions
diff --git a/3rdparty/bx/include/bx/mpscqueue.h b/3rdparty/bx/include/bx/mpscqueue.h index de4a6646db3..0ac8f82915a 100644 --- a/3rdparty/bx/include/bx/mpscqueue.h +++ b/3rdparty/bx/include/bx/mpscqueue.h @@ -6,48 +6,42 @@ #ifndef BX_MPSCQUEUE_H_HEADER_GUARD #define BX_MPSCQUEUE_H_HEADER_GUARD +#include "mutex.h" #include "spscqueue.h" namespace bx { + /// template <typename Ty> - class MpScUnboundedQueue + class MpScUnboundedQueueT { - BX_CLASS(MpScUnboundedQueue + BX_CLASS(MpScUnboundedQueueT , NO_COPY , NO_ASSIGNMENT ); public: - MpScUnboundedQueue() - { - } - - ~MpScUnboundedQueue() - { - } - - void push(Ty* _ptr) // producer only - { - LwMutexScope lock(m_write); - m_queue.push(_ptr); - } - - Ty* peek() // consumer only - { - return m_queue.peek(); - } - - Ty* pop() // consumer only - { - return m_queue.pop(); - } + /// + MpScUnboundedQueueT(); + + /// + ~MpScUnboundedQueueT(); + + /// + void push(Ty* _ptr); // producer only + + /// + Ty* peek(); // consumer only + + /// + Ty* pop(); // consumer only private: - LwMutex m_write; - SpScUnboundedQueue<Ty> m_queue; + Mutex m_write; + SpScUnboundedQueueT<Ty> m_queue; }; + /// template <typename Ty> class MpScUnboundedBlockingQueue { @@ -57,31 +51,25 @@ namespace bx ); public: - MpScUnboundedBlockingQueue() - { - } - - ~MpScUnboundedBlockingQueue() - { - } - - void push(Ty* _ptr) // producer only - { - m_queue.push(_ptr); - m_sem.post(); - } - - Ty* pop() // consumer only - { - m_sem.wait(); - return m_queue.pop(); - } + /// + MpScUnboundedBlockingQueue(); + + /// + ~MpScUnboundedBlockingQueue(); + + /// + void push(Ty* _ptr); // producer only + + /// + Ty* pop(); // consumer only private: - MpScUnboundedQueue<Ty> m_queue; + MpScUnboundedQueueT<Ty> m_queue; Semaphore m_sem; }; } // namespace bx +#include "inline/mpscqueue.inl" + #endif // BX_MPSCQUEUE_H_HEADER_GUARD |