Public Member Functions | List of all members
ecvl::ProducersConsumerQueue Class Reference

Class that manages the producers-consumer queue of samples. The queue stores pairs of image and label, pushing and popping them in an exclusive way. The queue also has a maximum size (max_size_ attribute) to avoid memory overflows. More...

#include <support_eddl.h>

Public Member Functions

 ProducersConsumerQueue ()
 
 ProducersConsumerQueue (unsigned mxsz)
 
 ProducersConsumerQueue (unsigned mxsz, unsigned thresh)
 
void Push (const Sample &sample, Tensor *const image, Tensor *const label)
 Push a sample in the queue. More...
 
void Pop (Sample &sample, Tensor *&image, Tensor *&label)
 Pop a sample from the queue. More...
 
bool IsFull () const
 Check if the queue is full. More...
 
bool IsEmpty () const
 Check if the queue is empty. More...
 
size_t Length () const
 Calculate the current size of the queue. More...
 
void SetSize (int max_size, int thresh=-1)
 Set the maximum size of the queue and optionally the threshold from which restart to produce samples. More...
 
void Clear ()
 

Detailed Description

Class that manages the producers-consumer queue of samples. The queue stores pairs of image and label, pushing and popping them in an exclusive way. The queue also has a maximum size (max_size_ attribute) to avoid memory overflows.

Definition at line 143 of file support_eddl.h.

Constructor & Destructor Documentation

◆ ProducersConsumerQueue() [1/3]

ecvl::ProducersConsumerQueue::ProducersConsumerQueue ( )
inline

Definition at line 153 of file support_eddl.h.

◆ ProducersConsumerQueue() [2/3]

ecvl::ProducersConsumerQueue::ProducersConsumerQueue ( unsigned  mxsz)
inline
Parameters
[in]mxszMaximum size of the queue.

Definition at line 157 of file support_eddl.h.

◆ ProducersConsumerQueue() [3/3]

ecvl::ProducersConsumerQueue::ProducersConsumerQueue ( unsigned  mxsz,
unsigned  thresh 
)
inline
Parameters
[in]mxszMaximum size of the queue.
[in]threshThreshold from which restart to produce samples.

Definition at line 162 of file support_eddl.h.

Member Function Documentation

◆ Clear()

void ecvl::ProducersConsumerQueue::Clear ( )
inline

Definition at line 241 of file support_eddl.h.

◆ IsEmpty()

bool ecvl::ProducersConsumerQueue::IsEmpty ( ) const
inline

Check if the queue is empty.

Returns
true if the queue is empty, false otherwise.

Definition at line 214 of file support_eddl.h.

◆ IsFull()

bool ecvl::ProducersConsumerQueue::IsFull ( ) const
inline

Check if the queue is full.

Returns
true if the queue is full, false otherwise.

Definition at line 204 of file support_eddl.h.

◆ Length()

size_t ecvl::ProducersConsumerQueue::Length ( ) const
inline

Calculate the current size of the queue.

Returns
the current size of the queue.

Definition at line 224 of file support_eddl.h.

◆ Pop()

void ecvl::ProducersConsumerQueue::Pop ( Sample sample,
Tensor *&  image,
Tensor *&  label 
)
inline

Pop a sample from the queue.

Take the lock of the queue and wait if the queue is empty. Otherwise, pop a sample, an image and its label from the queue. If the queue size is still bigger than the half of the maximum size, don't notify the Push to avoid an always-full queue.

Parameters
[in]sampleSample to pop from the queue.
[in]imageTensor* of the image to pop from the queue.
[in]labelTensor* of the label to pop from the queue.

Definition at line 189 of file support_eddl.h.

◆ Push()

void ecvl::ProducersConsumerQueue::Push ( const Sample sample,
Tensor *const  image,
Tensor *const  label 
)
inline

Push a sample in the queue.

Take the lock of the queue and wait if the queue is full. Otherwise, push the tuple sample, image and label into the queue.

Parameters
[in]sampleSample to push in queue.
[in]imageTensor* to the image to push in the queue.
[in]labelTensor* to the label to push in the queue.

Definition at line 172 of file support_eddl.h.

◆ SetSize()

void ecvl::ProducersConsumerQueue::SetSize ( int  max_size,
int  thresh = -1 
)
inline

Set the maximum size of the queue and optionally the threshold from which restart to produce samples.

Parameters
[in]max_sizemaximum size of the queue.
[in]threshthreshold from which restart to produce samples. If not specified, it's set to the half of maximum size.

Definition at line 235 of file support_eddl.h.


The documentation for this class was generated from the following file: