31#ifndef ETL_SPSC_QUEUE_LOCKED_INCLUDED
32#define ETL_SPSC_QUEUE_LOCKED_INCLUDED
48 template <
size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
121 if (index == maximum) ETL_UNLIKELY
171#if defined(ETL_POLYMORPHIC_SPSC_QUEUE_ISR) || defined(ETL_POLYMORPHIC_CONTAINERS)
191 template <
typename T, const
size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
204 typedef T&& rvalue_reference;
213 return push_implementation(value);
223 bool result = push_implementation(value);
230#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKED_FORCE_CPP03_IMPLEMENTATION)
237 return push_implementation(etl::move(value));
244 bool push(rvalue_reference value)
248 bool result = push_implementation(etl::move(value));
256#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKED_FORCE_CPP03_IMPLEMENTATION)
261 template <
typename ... Args>
264 return emplace_implementation(etl::forward<Args>(args)...);
271 template <
typename ... Args>
276 bool result = emplace_implementation(etl::forward<Args>(args)...);
287 template <
typename T1>
290 return emplace_implementation(value1);
297 template <
typename T1,
typename T2>
300 return emplace_implementation(value1, value2);
307 template <
typename T1,
typename T2,
typename T3>
310 return emplace_implementation(value1, value2, value3);
317 template <
typename T1,
typename T2,
typename T3,
typename T4>
320 return emplace_implementation(value1, value2, value3, value4);
327 template <
typename T1>
332 bool result = emplace_implementation(value1);
343 template <
typename T1,
typename T2>
344 bool emplace(
const T1& value1,
const T2& value2)
348 bool result = emplace_implementation(value1, value2);
359 template <
typename T1,
typename T2,
typename T3>
360 bool emplace(
const T1& value1,
const T2& value2,
const T3& value3)
364 bool result = emplace_implementation(value1, value2, value3);
375 template <
typename T1,
typename T2,
typename T3,
typename T4>
376 bool emplace(
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
380 bool result = emplace_implementation(value1, value2, value3, value4);
394 return pop_implementation(value);;
404 bool result = pop_implementation(value);
417 return pop_implementation();
427 bool result = pop_implementation();
440 return front_implementation();
449 return front_implementation();
459 reference result = front_implementation();
485 while (pop_implementation())
498 while (pop_implementation())
569 , p_buffer(p_buffer_)
597#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKED_FORCE_CPP03_IMPLEMENTATION)
602 bool push_implementation(rvalue_reference value)
606 ::new (&p_buffer[this->
write_index]) T(etl::move(value));
620#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKED_FORCE_CPP03_IMPLEMENTATION)
625 template <
typename ... Args>
626 bool emplace_implementation(Args&&... args)
630 ::new (&p_buffer[this->
write_index]) T(etl::forward<Args>(args)...);
646 template <
typename T1>
647 bool emplace_implementation(
const T1& value1)
667 template <
typename T1,
typename T2>
668 bool emplace_implementation(
const T1& value1,
const T2& value2)
672 ::new (&p_buffer[this->
write_index]) T(value1, value2);
688 template <
typename T1,
typename T2,
typename T3>
689 bool emplace_implementation(
const T1& value1,
const T2& value2,
const T3& value3)
693 ::new (&p_buffer[this->
write_index]) T(value1, value2, value3);
709 template <
typename T1,
typename T2,
typename T3,
typename T4>
710 bool emplace_implementation(
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
714 ::new (&p_buffer[this->
write_index]) T(value1, value2, value3, value4);
740#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKABLE_FORCE_CPP03_IMPLEMENTATION)
741 value = etl::move(p_buffer[this->
read_index]);
759 reference front_implementation()
768 const_reference front_implementation()
const
777 bool pop_implementation()
817 template <
typename T,
size_t SIZE, const
size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
830 static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE);
838 :
base_t(reinterpret_cast<T*>(buffer.raw), MAX_SIZE, lock, unlock)
864 template <
typename T,
size_t SIZE, const
size_t MEMORY_MODEL>
865 ETL_CONSTANT
typename queue_spsc_locked<T, SIZE, MEMORY_MODEL>::size_type queue_spsc_locked<T, SIZE, MEMORY_MODEL>::MAX_SIZE;
Definition: queue_spsc_locked.h:50
size_type available_from_unlocked() const
How much free space available in the queue.
Definition: queue_spsc_locked.h:59
const size_type MAX_SIZE
The maximum number of items in the queue.
Definition: queue_spsc_locked.h:132
bool empty_implementation() const
Is the queue empty?
Definition: queue_spsc_locked.h:163
size_type available_implementation() const
How much free space available in the queue.
Definition: queue_spsc_locked.h:139
bool full_from_unlocked() const
Is the queue full?
Definition: queue_spsc_locked.h:67
bool empty_from_unlocked() const
Is the queue empty?
Definition: queue_spsc_locked.h:83
size_type max_size() const
How many items can the queue hold.
Definition: queue_spsc_locked.h:99
size_type size_from_unlocked() const
How many items in the queue?
Definition: queue_spsc_locked.h:75
size_type current_size
The current size of the queue.
Definition: queue_spsc_locked.h:131
size_type write_index
Where to input new data.
Definition: queue_spsc_locked.h:129
bool full_implementation() const
Is the queue full?
Definition: queue_spsc_locked.h:147
etl::size_type_lookup< MEMORY_MODEL >::type size_type
The type used for determining the size of queue.
Definition: queue_spsc_locked.h:54
size_type capacity() const
How many items can the queue hold.
Definition: queue_spsc_locked.h:91
~iqueue_spsc_locked_base()
Destructor.
Definition: queue_spsc_locked.h:178
static size_type get_next_index(size_type index, size_type maximum)
Calculate the next index.
Definition: queue_spsc_locked.h:117
size_type read_index
Where to get the oldest data.
Definition: queue_spsc_locked.h:130
size_type size_implementation() const
How many items in the queue?
Definition: queue_spsc_locked.h:155
This is the base for all queue_spsc_locked that contain a particular type.
Definition: queue_spsc_locked.h:193
bool emplace(const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Definition: queue_spsc_locked.h:376
bool emplace(const T1 &value1)
Definition: queue_spsc_locked.h:328
bool pop_from_unlocked()
Definition: queue_spsc_locked.h:415
bool emplace_from_unlocked(const T1 &value1)
Definition: queue_spsc_locked.h:288
reference front_from_unlocked()
Definition: queue_spsc_locked.h:438
bool emplace(const T1 &value1, const T2 &value2, const T3 &value3)
Definition: queue_spsc_locked.h:360
bool emplace(const T1 &value1, const T2 &value2)
Definition: queue_spsc_locked.h:344
bool emplace_from_unlocked(const T1 &value1, const T2 &value2)
Definition: queue_spsc_locked.h:298
iqueue_spsc_locked(T *p_buffer_, size_type max_size_, const etl::ifunction< void > &lock_, const etl::ifunction< void > &unlock_)
The constructor that is called from derived classes.
Definition: queue_spsc_locked.h:567
T & reference
A reference to the type used in the queue.
Definition: queue_spsc_locked.h:201
bool pop()
Pop a value from the queue and discard.
Definition: queue_spsc_locked.h:423
bool pop(reference value)
Pop a value from the queue.
Definition: queue_spsc_locked.h:400
void clear()
Clear the queue.
Definition: queue_spsc_locked.h:494
bool emplace_from_unlocked(const T1 &value1, const T2 &value2, const T3 &value3)
Definition: queue_spsc_locked.h:308
reference front()
Peek a value from the front of the queue.
Definition: queue_spsc_locked.h:455
T value_type
The type stored in the queue.
Definition: queue_spsc_locked.h:200
const T & const_reference
A const reference to the type used in the queue.
Definition: queue_spsc_locked.h:202
const_reference front_from_unlocked() const
Definition: queue_spsc_locked.h:447
bool empty() const
Is the queue empty?
Definition: queue_spsc_locked.h:551
size_type size() const
How many items in the queue?
Definition: queue_spsc_locked.h:537
bool push_from_unlocked(const_reference value)
Push a value to the queue.
Definition: queue_spsc_locked.h:211
base_t::size_type size_type
The type used for determining the size of the queue.
Definition: queue_spsc_locked.h:206
bool emplace_from_unlocked(const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Definition: queue_spsc_locked.h:318
const_reference front() const
Peek a value from the front of the queue.
Definition: queue_spsc_locked.h:469
bool full() const
Is the queue full?
Definition: queue_spsc_locked.h:523
void clear_from_unlocked()
Clear the queue from the ISR.
Definition: queue_spsc_locked.h:483
bool push(const_reference value)
Push a value to the queue.
Definition: queue_spsc_locked.h:219
size_type available() const
How much free space available in the queue.
Definition: queue_spsc_locked.h:509
bool pop_from_unlocked(reference value)
Definition: queue_spsc_locked.h:392
Definition: queue_spsc_locked.h:819
~queue_spsc_locked()
Destructor.
Definition: queue_spsc_locked.h:845
queue_spsc_locked(const etl::ifunction< void > &lock, const etl::ifunction< void > &unlock)
Default constructor.
Definition: queue_spsc_locked.h:836
Definition: function.h:73
Definition: integral_limits.h:468
bitset_ext
Definition: absolute.h:38
Definition: memory_model.h:50