5#include <Utility/Concurrent/TAtomicQuasiQueue.h>
6#include <Common/assertion.h>
19template<
typename Target>
34 TAtomicQuasiQueue<TQuery<Target>> m_queries;
35 std::vector<TQuery<Target>> m_queryCache;
38 std::thread::id m_processingThreadId;
42template<
typename Target>
45 m_queries.enqueue(std::move(query));
48template<
typename Target>
52 if(m_processingThreadId == std::thread::id{})
54 m_processingThreadId = std::this_thread::get_id();
56 PH_ASSERT(std::this_thread::get_id() == m_processingThreadId);
60 while(m_queries.tryDequeue(&query))
68 if(!query.
run(target))
70 m_queryCache.push_back(std::move(query));
75 m_queries.enqueueBulk(std::make_move_iterator(m_queryCache.begin()), m_queryCache.size());
Definition TConcurrentQueryManager.h:21
void processQueries(Target &target)
Process all added queries. Need to be called on the same thread consistently.
Definition TConcurrentQueryManager.h:49
void addQuery(TQuery< Target > query)
Add a query from any thread.
Definition TConcurrentQueryManager.h:43
bool isCanceled() const
Whether the query is canceled.
Definition TQuery.ipp:88
void clear()
Clear the underlying query performer. After this call, isEmpty() is true.
Definition TQuery.h:99
bool run(Target &target)
Definition TQuery.ipp:40
Definition ph_editor.h:10