31#ifndef ETL_QUEUE_LOCKABLE_INCLUDED
32#define ETL_QUEUE_LOCKABLE_INCLUDED
48 template <
size_t VMemory_Model = etl::memory_model::MEMORY_MODEL_LARGE>
69 return available_implementation();
79 size_type result = available_implementation();
92 return empty_implementation();
102 size_type result = empty_implementation();
115 return full_implementation();
125 size_type result = full_implementation();
138 return size_implementation();
148 size_type result = size_implementation();
188 if (index == maximum) ETL_UNLIKELY
200 virtual void unlock()
const = 0;
212 size_type available_implementation()
const
220 bool empty_implementation()
const
228 bool full_implementation()
const
248 template <
typename T, const
size_t VMemory_Model = etl::memory_model::MEMORY_MODEL_LARGE>
261 typedef T&& rvalue_reference;
270 return push_implementation(value);
280 bool result = push_implementation(value);
287#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKABLE_FORCE_CPP03_IMPLEMENTATION)
293 return push_implementation(value);
299 bool push(rvalue_reference value)
303 bool result = push_implementation(etl::move(value));
311#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKABLE_FORCE_CPP03_IMPLEMENTATION)
315 template <
typename ... Args>
318 return emplace_implementation(etl::forward<Args>(args)...);
324 template <
typename ... Args>
329 bool result = emplace_implementation(etl::forward<Args>(args)...);
339 template <
typename T1>
342 return emplace_implementation(value1);
348 template <
typename T1,
typename T2>
351 return emplace_implementation(value1, value2);
357 template <
typename T1,
typename T2,
typename T3>
360 return emplace_implementation(value1, value2, value3);
366 template <
typename T1,
typename T2,
typename T3,
typename T4>
367 bool emplace_unlocked(
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
369 return emplace_implementation(value1, value2, value3, value4);
375 template <
typename T1>
380 bool result = emplace_implementation(value1);
390 template <
typename T1,
typename T2>
391 bool emplace(
const T1& value1,
const T2& value2)
395 bool result = emplace_implementation(value1, value2);
405 template <
typename T1,
typename T2,
typename T3>
406 bool emplace(
const T1& value1,
const T2& value2,
const T3& value3)
410 bool result = emplace_implementation(value1, value2, value3);
420 template <
typename T1,
typename T2,
typename T3,
typename T4>
421 bool emplace(
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
425 bool result = emplace_implementation(value1, value2, value3, value4);
438 return pop_implementation();
449 bool result = pop_implementation();
461 return pop_implementation(value);
471 bool result = pop_implementation(value);
483 return front_implementation();
491 return front_implementation();
501 reference result = front_implementation();
515 const_reference result = front_implementation();
527 while (pop_implementation())
540 while (pop_implementation())
555 , p_buffer(p_buffer_)
566 if (this->current_size != this->Max_Size)
568 ::new (&p_buffer[this->write_index]) T(value);
570 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
581#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKABLE_FORCE_CPP03_IMPLEMENTATION)
585 bool push_implementation(rvalue_reference value)
587 if (this->current_size != this->Max_Size)
589 ::new (&p_buffer[this->write_index]) T(etl::move(value));
591 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
603#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKABLE_FORCE_CPP03_IMPLEMENTATION)
607 template <
typename ... Args>
608 bool emplace_implementation(Args&&... args)
610 if (this->current_size != this->Max_Size)
612 ::new (&p_buffer[this->write_index]) T(etl::forward<Args>(args)...);
614 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
628 template <
typename T1>
629 bool emplace_implementation(
const T1& value1)
631 if (this->current_size != this->Max_Size)
633 ::new (&p_buffer[this->write_index]) T(value1);
635 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
649 template <
typename T1,
typename T2>
650 bool emplace_implementation(
const T1& value1,
const T2& value2)
652 if (this->current_size != this->Max_Size)
654 ::new (&p_buffer[this->write_index]) T(value1, value2);
656 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
670 template <
typename T1,
typename T2,
typename T3>
671 bool emplace_implementation(
const T1& value1,
const T2& value2,
const T3& value3)
673 if (this->current_size != this->Max_Size)
675 ::new (&p_buffer[this->write_index]) T(value1, value2, value3);
677 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
691 template <
typename T1,
typename T2,
typename T3,
typename T4>
692 bool emplace_implementation(
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
694 if (this->current_size != this->Max_Size)
696 ::new (&p_buffer[this->write_index]) T(value1, value2, value3, value4);
698 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
713 bool pop_implementation()
715 if (this->current_size == 0)
723 this->read_index = this->
get_next_index(this->read_index, this->Max_Size);
735 if (this->current_size == 0)
741#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKABLE_FORCE_CPP03_IMPLEMENTATION)
742 value = etl::move(p_buffer[this->read_index]);
749 this->read_index = this->
get_next_index(this->read_index, this->Max_Size);
759 reference front_implementation()
767 const_reference front_implementation()
const
791 template <
typename T,
size_t VSize,
size_t VMemory_Model = etl::memory_model::MEMORY_MODEL_LARGE>
804 static ETL_CONSTANT size_type Max_Size = size_type(VSize);
805 static ETL_CONSTANT size_type Memory_Model = size_type(VMemory_Model);
812 :
base_t(reinterpret_cast<T*>(buffer.raw), Max_Size)
841 template <
typename T,
size_t VSize,
size_t VMemory_Model>
842 ETL_CONSTANT
typename queue_lockable<T, VSize, VMemory_Model>::size_type queue_lockable<T, VSize, VMemory_Model>::Max_Size;
844 template <
typename T,
size_t VSize,
size_t VMemory_Model>
845 ETL_CONSTANT
typename queue_lockable<T, VSize, VMemory_Model>::size_type queue_lockable<T, VSize, VMemory_Model>::Memory_Model;
This is the base for all queues that contain a particular type.
Definition: queue_lockable.h:250
bool pop(reference value)
Pop a value from the queue.
Definition: queue_lockable.h:467
reference front_unlocked()
Peek a value at the front of the queue without locking.
Definition: queue_lockable.h:481
bool pop_unlocked(reference value)
Pop a value from the queue without locking.
Definition: queue_lockable.h:459
bool pop()
Pop a value from the queue and discard.
Definition: queue_lockable.h:445
reference front()
Peek a value at the front of the queue.
Definition: queue_lockable.h:497
bool emplace(const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Constructs a value in the queue 'in place'.
Definition: queue_lockable.h:421
bool emplace(const T1 &value1)
Constructs a value in the queue 'in place'.
Definition: queue_lockable.h:376
void clear()
Clear the queue.
Definition: queue_lockable.h:536
bool emplace_unlocked(const T1 &value1, const T2 &value2, const T3 &value3)
Constructs a value in the queue 'in place'.
Definition: queue_lockable.h:358
const_reference front_unlocked() const
Peek a value at the front of the queue without locking.
Definition: queue_lockable.h:489
bool emplace_unlocked(const T1 &value1)
Constructs a value in the queue 'in place'.
Definition: queue_lockable.h:340
bool push_unlocked(const_reference value)
Push a value to the queue without locking.
Definition: queue_lockable.h:268
bool pop_unlocked()
Pop a value from the queue without locking, and discard.
Definition: queue_lockable.h:436
bool emplace(const T1 &value1, const T2 &value2, const T3 &value3)
Constructs a value in the queue 'in place'.
Definition: queue_lockable.h:406
bool emplace_unlocked(const T1 &value1, const T2 &value2)
Constructs a value in the queue 'in place'.
Definition: queue_lockable.h:349
iqueue_lockable(T *p_buffer_, size_type max_size_)
The constructor that is called from derived classes.
Definition: queue_lockable.h:553
bool emplace(const T1 &value1, const T2 &value2)
Constructs a value in the queue 'in place'.
Definition: queue_lockable.h:391
base_t::size_type size_type
The type used for determining the size of the queue.
Definition: queue_lockable.h:263
const_reference front() const
Peek a value at the front of the queue.
Definition: queue_lockable.h:511
const T & const_reference
A const reference to the type used in the queue.
Definition: queue_lockable.h:259
T value_type
The type stored in the queue.
Definition: queue_lockable.h:257
bool emplace_unlocked(const T1 &value1, const T2 &value2, const T3 &value3, const T4 &value4)
Constructs a value in the queue 'in place'.
Definition: queue_lockable.h:367
bool push(const_reference value)
Push a value to the queue.
Definition: queue_lockable.h:276
void clear_unlocked()
Clear the queue, unlocked.
Definition: queue_lockable.h:525
T & reference
A reference to the type used in the queue.
Definition: queue_lockable.h:258
Definition: queue_lockable.h:50
size_type size_unlocked() const
Definition: queue_lockable.h:136
size_type capacity() const
How many items can the queue hold.
Definition: queue_lockable.h:158
size_type max_size() const
How many items can the queue hold.
Definition: queue_lockable.h:166
bool empty() const
Is the queue empty?
Definition: queue_lockable.h:98
bool empty_unlocked() const
Definition: queue_lockable.h:90
const size_type Max_Size
The maximum number of items in the queue.
Definition: queue_lockable.h:205
size_type read_index
Where to get the oldest data.
Definition: queue_lockable.h:203
size_type current_size
The current size of the queue.
Definition: queue_lockable.h:204
size_type available_unlocked() const
Definition: queue_lockable.h:67
etl::size_type_lookup< VMemory_Model >::type size_type
The type used for determining the size of queue.
Definition: queue_lockable.h:54
size_type write_index
Where to input new data.
Definition: queue_lockable.h:202
static size_type get_next_index(size_type index, size_type maximum)
Calculate the next index.
Definition: queue_lockable.h:184
size_type size() const
How many items in the queue?
Definition: queue_lockable.h:144
virtual void lock() const =0
The pure virtual lock and unlock functions.
bool full_unlocked() const
Definition: queue_lockable.h:113
size_type available() const
How much free space available in the queue.
Definition: queue_lockable.h:75
bool full() const
Is the queue full?
Definition: queue_lockable.h:121
virtual ~queue_lockable_base()
Destructor.
Definition: queue_lockable.h:59
Definition: queue_lockable.h:793
~queue_lockable()
Destructor.
Definition: queue_lockable.h:819
queue_lockable()
Default constructor.
Definition: queue_lockable.h:811
Definition: integral_limits.h:468
bitset_ext
Definition: absolute.h:38
Definition: memory_model.h:50