Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TBlockableAtomicQuasiQueue.h
Go to the documentation of this file.
1#pragma once
2
3#include <moodycamel/blockingconcurrentqueue.h>
4
5#include <cstddef>
6#include <iterator>
7
8namespace ph
9{
10
20template<typename T>
22{
23public:
25 explicit TBlockableAtomicQuasiQueue(std::size_t initialCapacity);
26
33 template<typename U>
34 void enqueue(U&& item);
35
39 template<std::input_iterator Iterator>
40 void enqueueBulk(Iterator firstItem, std::size_t numItems);
41
46 template<typename U>
47 bool tryEnqueue(U&& item);
48
57 bool tryDequeue(T* out_item);
58
62 void waitDequeue(T* out_item);
63
64 template<std::output_iterator<T> Iterator>
65 std::size_t waitDequeueBulk(Iterator out_firstItem, std::size_t numItems);
66
72 std::size_t estimatedSize() const;
73
74private:
75 /*
76 For more information about the queue, please see the documentation of `TAtomicQuasiQueue::m_queue` as they
77 share similar properties.
78 */
79 moodycamel::BlockingConcurrentQueue<T> m_queue;
80};
81
82}// end namespace ph
83
Blockable version of the TAtomicQuasiQueue. For single-thread uses, it is a FIFO queue....
Definition TBlockableAtomicQuasiQueue.h:22
bool tryEnqueue(U &&item)
Try to enqueue an item. Never allocate memory.
Definition TBlockableAtomicQuasiQueue.ipp:45
void enqueueBulk(Iterator firstItem, std::size_t numItems)
Enqueue multiple items at once. Similar to enqueue(1). Use std::make_move_iterator if the items shoul...
Definition TBlockableAtomicQuasiQueue.ipp:34
void waitDequeue(T *out_item)
Blocks the current thread until there is something to dequeue.
Definition TBlockableAtomicQuasiQueue.ipp:58
TBlockableAtomicQuasiQueue()
Definition TBlockableAtomicQuasiQueue.ipp:12
void enqueue(U &&item)
Enqueue an item. Allocate memory if required. Basic aquire-release semantics are guaranteed....
Definition TBlockableAtomicQuasiQueue.ipp:23
bool tryDequeue(T *out_item)
Try to dequeue an item. While there is no contention, dequeue fails if there is no item or the memory...
Definition TBlockableAtomicQuasiQueue.ipp:51
std::size_t estimatedSize() const
Approximated size of the queue.
Definition TBlockableAtomicQuasiQueue.ipp:72
std::size_t waitDequeueBulk(Iterator out_firstItem, std::size_t numItems)
Definition TBlockableAtomicQuasiQueue.ipp:66
The root for all renderer implementations.
Definition EEngineProject.h:6