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>
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>
324 template <
typename ... 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>
369 return emplace_implementation(value1, value2, value3, value4);
379 bool result = emplace_implementation();
389 template <
typename T1>
394 bool result = emplace_implementation(value1);
404 template <
typename T1,
typename T2>
409 bool result = emplace_implementation(value1, value2);
419 template <
typename T1,
typename T2,
typename T3>
424 bool result = emplace_implementation(value1, value2, value3);
434 template <
typename T1,
typename T2,
typename T3,
typename T4>
439 bool result = emplace_implementation(value1, value2, value3, value4);
452 return pop_implementation();
463 bool result = pop_implementation();
475 return pop_implementation(value);
485 bool result = pop_implementation(value);
497 return front_implementation();
505 return front_implementation();
515 reference result = front_implementation();
529 const_reference result = front_implementation();
541 while (pop_implementation())
554 while (pop_implementation())
580 if (this->current_size != this->Max_Size)
582 ::new (&p_buffer[this->write_index])
T(value);
584 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
595#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKABLE_FORCE_CPP03_IMPLEMENTATION)
599 bool push_implementation(rvalue_reference value)
601 if (this->current_size != this->Max_Size)
603 ::new (&p_buffer[this->write_index]) T(etl::move(value));
605 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
617#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKABLE_FORCE_CPP03_IMPLEMENTATION)
621 template <
typename ... Args>
622 bool emplace_implementation(Args&&... args)
624 if (this->current_size != this->Max_Size)
628 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
642 template <
typename T1>
643 bool emplace_implementation(
const T1& value1)
645 if (this->current_size != this->Max_Size)
647 ::new (&p_buffer[this->write_index]) T(value1);
649 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
663 template <
typename T1,
typename T2>
664 bool emplace_implementation(
const T1& value1,
const T2& value2)
666 if (this->current_size != this->Max_Size)
668 ::new (&p_buffer[this->write_index]) T(value1, value2);
670 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
684 template <
typename T1,
typename T2,
typename T3>
685 bool emplace_implementation(
const T1& value1,
const T2& value2,
const T3& value3)
687 if (this->current_size != this->Max_Size)
689 ::new (&p_buffer[this->write_index]) T(value1, value2, value3);
691 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
705 template <
typename T1,
typename T2,
typename T3,
typename T4>
706 bool emplace_implementation(
const T1& value1,
const T2& value2,
const T3& value3,
const T4& value4)
708 if (this->current_size != this->Max_Size)
710 ::new (&p_buffer[this->write_index]) T(value1, value2, value3, value4);
712 this->write_index = this->
get_next_index(this->write_index, this->Max_Size);
727 bool pop_implementation()
729 if (this->current_size == 0)
737 this->read_index = this->
get_next_index(this->read_index, this->Max_Size);
749 if (this->current_size == 0)
755#if ETL_USING_CPP11 && ETL_NOT_USING_STLPORT && !defined(ETL_QUEUE_LOCKABLE_FORCE_CPP03_IMPLEMENTATION)
756 value = etl::move(p_buffer[this->read_index]);
763 this->read_index = this->
get_next_index(this->read_index, this->Max_Size);
773 reference front_implementation()
781 const_reference front_implementation()
const
805 template <
typename T,
size_t VSize,
size_t VMemory_Model = etl::memory_model::MEMORY_MODEL_LARGE>
818 static ETL_CONSTANT size_type Max_Size = size_type(
VSize);
819 static ETL_CONSTANT size_type Memory_Model = size_type(
VMemory_Model);
855 template <
typename T,
size_t VSize,
size_t VMemory_Model>
856 ETL_CONSTANT
typename queue_lockable<T, VSize, VMemory_Model>::size_type queue_lockable<T, VSize, VMemory_Model>::Max_Size;
858 template <
typename T,
size_t VSize,
size_t VMemory_Model>
859 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:481
reference front_unlocked()
Peek a value at the front of the queue without locking.
Definition queue_lockable.h:495
bool pop_unlocked(reference value)
Pop a value from the queue without locking.
Definition queue_lockable.h:473
bool pop()
Pop a value from the queue and discard.
Definition queue_lockable.h:459
reference front()
Peek a value at the front of the queue.
Definition queue_lockable.h:511
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:435
bool emplace(const T1 &value1)
Constructs a value in the queue 'in place'.
Definition queue_lockable.h:390
void clear()
Clear the queue.
Definition queue_lockable.h:550
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:503
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:450
bool emplace(const T1 &value1, const T2 &value2, const T3 &value3)
Constructs a value in the queue 'in place'.
Definition queue_lockable.h:420
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:567
bool emplace(const T1 &value1, const T2 &value2)
Constructs a value in the queue 'in place'.
Definition queue_lockable.h:405
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:525
bool emplace()
Constructs a value in the queue 'in place'.
Definition queue_lockable.h:375
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:539
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:807
~queue_lockable()
Destructor.
Definition queue_lockable.h:833
queue_lockable()
Default constructor.
Definition queue_lockable.h:825
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