# Barry::DataQueue Class Reference

`#include <dataqueue.h>`

List of all members.

## Detailed Description

This class provides a thread aware fifo queue for Data objects, providing memory management for all Data object pointers it contains.

It uses similar member names as std::queue<>, for consistency.

Definition at line 40 of file dataqueue.h.

## Public Member Functions

void | push (Data *data)
| Pushes data into the end of the queue.
Data * | pop ()
| Pops the next element off the front of the queue.
Data * | wait_pop (int timeout=-1)
| Pops the next element off the front of the queue, and waits until one exists if empty.
void | append_from (DataQueue &other)
| Pops all data from other and appends it to this.
bool | empty () const
| Returns true if the queue is empty.
size_t | size () const
| Returns number of items in the queue.

## Member Function Documentation

void Barry::DataQueue::push | ( | Data * | data | ) |

Pushes data into the end of the queue.

The queue owns this pointer as soon as the function is called. In the case of an exception, it will be freed. Performs a thread broadcast once new data has been added.

Definition at line 59 of file dataqueue.cc.

Data * Barry::DataQueue::pop | ( |  | ) |

Pops the next element off the front of the queue.

Returns 0 if empty. The queue no longer owns this pointer upon return.

Definition at line 86 of file dataqueue.cc.

Data * Barry::DataQueue::wait_pop | ( | int | timeout = `-1` | ) |

Pops the next element off the front of the queue, and waits until one exists if empty.

If still no data on timeout, returns null. (unlock the access mutex while waiting!)

Timeout specified in milliseconds. Default is wait forever.

Definition at line 108 of file dataqueue.cc.

References size(), and Barry::ThreadTimeout().

Here is the call graph for this function:

void Barry::DataQueue::append_from | ( | DataQueue & | other | ) |

Pops all data from other and appends it to this.

After calling this function, other will be empty, and this will contain all its data.

In the case of an exception, any uncopied data will remain in other.

This is a locking optimization, so all copying can happen inside one lock, instead of locking for each copy.

Definition at line 176 of file dataqueue.cc.

References m_accessMutex, and m_queue.

bool Barry::DataQueue::empty | ( |  | ) | const

Returns true if the queue is empty.

Definition at line 195 of file dataqueue.cc.

size_t Barry::DataQueue::size | ( |  | ) | const

Returns number of items in the queue.

Definition at line 206 of file dataqueue.cc.

Referenced by wait_pop().

Here is the caller graph for this function:

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

- dataqueue.h
- dataqueue.cc