#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2013 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_INPUT_CONCURRENTQUEUE_H #define NUCLEX_INPUT_CONCURRENTQUEUE_H #include "Nuclex/Input/Config.h" #if defined(_MSC_VER) #include #else #error Please implement the ConcurrentQueue for your platform #endif namespace Nuclex { namespace Input { // ------------------------------------------------------------------------------------------- // /// Queue that can be implemented potentially lock-free template class ConcurrentQueue { #if 0 /// Tries to take a peek at the next item that would be popped /// Receives the next item, if any /// /// True if the next item was available and could be peaked, false if the queue was empty /// public: bool TryPeek(TItem &outItem) const {} #endif /// Adds an item to the queue /// Item that will be added to the queue public: void Add(const TItem &item) { this->wrappedQueue.push(item); } /// Tries to take the oldest item from the queue /// Item that will be taken from the queue /// /// True if the item was taken from the queue, false if the queue was empty /// public: bool TryPop(TItem &outItem) { return this->wrappedQueue.try_pop(outItem); } #if 0 /// Performs an atomic increment of a number /// Value that will be incremented /// The incremented value private: std::size_t interlockedIncrement(std::size_t &value); #endif #if defined(_MSC_VER) /// Concurrent queue that is being wrapped private: Concurrency::concurrent_queue wrappedQueue; #endif }; // ------------------------------------------------------------------------------------------- // }} // namespace Nuclex::Input #endif // NUCLEX_INPUT_CONCURRENTQUEUE_H