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>
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>
271 template <
typename ... 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);
331 bool result = emplace_implementation();
342 template <
typename T1>
347 bool result = emplace_implementation(value1);
358 template <
typename T1,
typename T2>
363 bool result = emplace_implementation(value1, value2);
374 template <
typename T1,
typename T2,
typename T3>
379 bool result = emplace_implementation(value1, value2, value3);
390 template <
typename T1,
typename T2,
typename T3,
typename T4>
395 bool result = emplace_implementation(value1, value2, value3, value4);
409 return pop_implementation(value);;
419 bool result = pop_implementation(value);
432 return pop_implementation();
442 bool result = pop_implementation();
455 return front_implementation();
464 return front_implementation();
474 reference result = front_implementation();
500 while (pop_implementation())
513 while (pop_implementation())
612#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKED_FORCE_CPP03_IMPLEMENTATION)
617 bool push_implementation(rvalue_reference value)
621 ::new (&p_buffer[this->
write_index]) T(etl::move(value));
635#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKED_FORCE_CPP03_IMPLEMENTATION)
640 template <
typename ... Args>
641 bool emplace_implementation(Args&&... args)
661 bool emplace_implementation()
681 template <
typename T1>
682 bool emplace_implementation(
const T1& value1)
702 template <
typename T1,
typename T2>
703 bool emplace_implementation(
const T1& value1,
const T2& value2)
707 ::new (&p_buffer[this->
write_index]) T(value1, value2);
723 template <
typename T1,
typename T2,
typename T3>
724 bool emplace_implementation(
const T1& value1,
const T2& value2,
const T3& value3)
728 ::new (&p_buffer[this->
write_index]) T(value1, value2, value3);
744 template <
typename T1,
typename T2,
typename T3,
typename T4>
745 bool emplace_implementation(
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
749 ::new (&p_buffer[this->
write_index]) T(value1, value2, value3, value4);
775#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKABLE_FORCE_CPP03_IMPLEMENTATION)
776 value = etl::move(p_buffer[this->
read_index]);
794 reference front_implementation()
803 const_reference front_implementation()
const
812 bool pop_implementation()
852 template <
typename T,
size_t SIZE, const
size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
865 static ETL_CONSTANT size_type MAX_SIZE = size_type(SIZE);
899 template <
typename T,
size_t SIZE, const
size_t MEMORY_MODEL>
900 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:391
bool emplace(const T1 &value1)
Definition queue_spsc_locked.h:343
bool pop_from_unlocked()
Definition queue_spsc_locked.h:430
bool emplace_from_unlocked(const T1 &value1)
Definition queue_spsc_locked.h:288
reference front_from_unlocked()
Definition queue_spsc_locked.h:453
bool emplace(const T1 &value1, const T2 &value2, const T3 &value3)
Definition queue_spsc_locked.h:375
bool emplace(const T1 &value1, const T2 &value2)
Definition queue_spsc_locked.h:359
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:582
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:438
bool pop(reference value)
Pop a value from the queue.
Definition queue_spsc_locked.h:415
void clear()
Clear the queue.
Definition queue_spsc_locked.h:509
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:470
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:462
bool empty() const
Is the queue empty?
Definition queue_spsc_locked.h:566
size_type size() const
How many items in the queue?
Definition queue_spsc_locked.h:552
bool push_from_unlocked(const_reference value)
Push a value to the queue.
Definition queue_spsc_locked.h:211
bool emplace()
Definition queue_spsc_locked.h:327
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:484
bool full() const
Is the queue full?
Definition queue_spsc_locked.h:538
void clear_from_unlocked()
Clear the queue from the ISR.
Definition queue_spsc_locked.h:498
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:524
bool pop_from_unlocked(reference value)
Definition queue_spsc_locked.h:407
Definition queue_spsc_locked.h:854
queue_spsc_locked(const etl::ifunction< void > &lock_, const etl::ifunction< void > &unlock_)
Default constructor.
Definition queue_spsc_locked.h:871
~queue_spsc_locked()
Destructor.
Definition queue_spsc_locked.h:880
Definition integral_limits.h:516
bitset_ext
Definition absolute.h:38
pair holds two objects of arbitrary type
Definition utility.h:164
Definition memory_model.h:50