14 #ifndef FIXEDSIZEDEQUEWITHMUTEXES_HPP
15 #define FIXEDSIZEDEQUEWITHMUTEXES_HPP
19 #include <condition_variable>
20 #include <camp/camp.hpp>
22 #include "common/FixedSizeDeque.hpp"
23 #include "common/MultiMutexesLock.hpp"
28 template<
typename T,
typename INDEX_TYPE >
54 camp::resources::Resource{ camp::resources::Cuda{} }
56 camp::resources::Resource{ camp::resources::Host{} }
69 camp::resources::Event e;
73 LIFO_MARK_SCOPE( waitingForBuffer );
77 LIFO_MARK_SCOPE( copy );
94 camp::resources::Event e;
98 LIFO_MARK_SCOPE( waitingForBuffer );
105 LIFO_MARK_SCOPE( copy );
106 camp::resources::Resource r = this->
getStream();
107 e = LvArray::memcpy( r, array.toSlice(), this->front() );
111 m_notFullCond.notify_all();
128 LIFO_MARK_SCOPE( WaitForBufferToEmplace );
132 LIFO_MARK_SCOPE( WaitForBufferToPop );
136 LIFO_MARK_SCOPE( Transfert );
Implement a double ended queue with fixed number of fixed size buffer to be stored.
camp::resources::Resource getStream()
camp::resources::Event emplace_back(const LvArray::ArraySlice< T const, 1, 0, INDEX_TYPE2 > &src)
ArraySlice1DLarge back() const
camp::resources::Event emplace_front(const LvArray::ArraySlice< T const, 1, 0, INDEX_TYPE2 > &src)
void pop_back()
Removes last array of the queue.
void pop_front()
Removes first array of the queue.
ArraySlice1DLarge front() const
Associate mutexes with the fixedSizeDeque.
std::mutex m_frontMutex
Mutex to protect access to the front.
std::mutex m_emplaceMutex
Mutex to prevent two simulteaneous emplace (can be an issue for last one)
camp::resources::Event emplaceFront(arrayView1d< T > array)
std::condition_variable_any m_notEmptyCond
Condition used to notify when queue is not empty.
std::condition_variable_any m_notFullCond
Condition used to notify when queue is not full.
std::mutex m_popMutex
Mutex to prevent two simulteaneous pop (can be an issue for last one)
camp::resources::Event popFront(arrayView1d< T > array)
std::mutex m_backMutex
Mutex to protect access to the back.
void emplaceFrontFromBack(FixedSizeDequeWithMutexes< T, INDEX_TYPE > &q2)
FixedSizeDequeWithMutexes(int maxEntries, int valuesPerEntry, LvArray::MemorySpace space)
void emplaceBackFromFront(FixedSizeDequeWithMutexes< T, INDEX_TYPE > &q2)
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
auto make_multilock(Mutexes &&... mutexes)
Helper to construct MultiMutexesLock (usage auto lock = make_multilock( mutex1, mutex2,...