// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Memory/Memory.h" #define MOODYCAMEL_EXCEPTIONS_ENABLED 0 #include /// /// The default engine configuration for concurrentqueue. /// struct ConcurrentQueueSettings : public moodycamel::ConcurrentQueueDefaultTraits { // Use bigger blocks static const size_t BLOCK_SIZE = 256; // Use default engine memory allocator static inline void* malloc(size_t size) { return Allocator::Allocate((uint64)size); } // Use default engine memory allocator static inline void free(void* ptr) { return Allocator::Free(ptr); } }; /// /// Lock-free implementation of thread-safe queue. /// Based on: https://github.com/cameron314/concurrentqueue /// template class ConcurrentQueue : public moodycamel::ConcurrentQueue { public: typedef moodycamel::ConcurrentQueue Base; public: /// /// Gets an estimate of the total number of elements currently in the queue. /// FORCE_INLINE int32 Count() const { return static_cast(Base::size_approx()); } /// /// Adds item to the collection. /// /// The item to add. FORCE_INLINE void Add(const T& item) { enqueue(item); } /// /// Adds item to the collection. /// /// The item to add. FORCE_INLINE void Add(T&& item) { enqueue(item); } };