42 #ifndef CORE_LMTQUEUE_H_
43 #define CORE_LMTQUEUE_H_
48 template <
typename T,
size_t N>
55 : queue_(), mutex_(sc_gen_unique_name(
"mutex_")),
56 cond_not_empty_(sc_gen_unique_name(
"cond_not_empty_")), slots_(0) {
63 while (queue_.empty()) {
64 wait(cond_not_empty_);
67 auto item = queue_.front();
71 cond_not_full_.notify();
80 while (queue_.empty()) {
81 wait(cond_not_empty_);
84 item = queue_.front();
88 cond_not_full_.notify();
96 while (this->full()) {
103 cond_not_empty_.notify();
111 while (this->full()) {
112 wait(cond_not_full_);
115 queue_.push(std::move(item));
118 cond_not_empty_.notify();
121 size_t available()
const {
126 return (slots_ == N);
130 return queue_.empty();
134 std::queue<T> queue_;
136 sc_event cond_not_empty_, cond_not_full_;
141 #endif // CORE_LMTQUEUE_H_
A size-limited multiple-producer, multiple-consumer, thread-safe queue implemented using SystemC prim...
Definition: LMTQueue.h:49
void push(const T &item)
Push an item onto the LMTQueue.
Definition: LMTQueue.h:95
void pop(T &item)
Pop the top element from the LMTQueue and copy it into the output argument.
Definition: LMTQueue.h:79
void push(T &&item)
Push an item onto the LMTQueue (explicit move)
Definition: LMTQueue.h:110
T pop()
Pop the top element from the LMTQueue and return a copy.
Definition: LMTQueue.h:62
LMTQueue()
Construct a LMTQueue.
Definition: LMTQueue.h:54