16 #ifndef FIXEDSIZEDEQUEWITHMUTEXES_HPP
17 #define FIXEDSIZEDEQUEWITHMUTEXES_HPP
21 #include <condition_variable>
22 #include <camp/camp.hpp>
24 #include "common/FixedSizeDeque.hpp"
25 #include "common/MultiMutexesLock.hpp"
30 template<
typename T,
typename INDEX_TYPE >
56 camp::resources::Resource{ camp::resources::Cuda{} }
58 camp::resources::Resource{ camp::resources::Host{} }
71 camp::resources::Event e;
75 LIFO_MARK_SCOPE( waitingForBuffer );
79 LIFO_MARK_SCOPE( copy );
96 camp::resources::Event e;
100 LIFO_MARK_SCOPE( waitingForBuffer );
107 LIFO_MARK_SCOPE( copy );
108 camp::resources::Resource r = this->
getStream();
109 e = LvArray::memcpy( r, array.toSlice(), this->front() );
113 m_notFullCond.notify_all();
130 LIFO_MARK_SCOPE( WaitForBufferToEmplace );
134 LIFO_MARK_SCOPE( WaitForBufferToPop );
138 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,...