Public Member Functions

Barry::DataQueue Class Reference

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

#include <dataqueue.h>

Collaboration diagram for Barry::DataQueue:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void push (Data *data)
 Pushes data into the end of the queue.
Datapop ()
 Pops the next element off the front of the queue.
Datawait_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.

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 41 of file dataqueue.h.


Member Function Documentation

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 177 of file dataqueue.cc.

Referenced by Barry::SocketRoutingQueue::UnregisterInterest().

Here is the caller graph for this function:

bool Barry::DataQueue::empty (  )  const

Returns true if the queue is empty.

Definition at line 196 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 104 of file dataqueue.cc.

Referenced by Barry::SocketRoutingQueue::DoRead().

Here is the caller graph for this function:

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 84 of file dataqueue.cc.

Referenced by Barry::SocketRoutingQueue::AllocateBuffers(), and Barry::SocketRoutingQueue::ReturnBuffer().

Here is the caller graph for this function:

size_t Barry::DataQueue::size (  )  const

Returns number of items in the queue.

Definition at line 207 of file dataqueue.cc.

Referenced by Barry::SocketRoutingQueue::AllocateBuffers(), and wait_pop().

Here is the caller graph for this function:

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 120 of file dataqueue.cc.

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

Referenced by Barry::SocketRoutingQueue::DefaultRead(), and Barry::SocketRoutingQueue::SocketRead().

Here is the call graph for this function:

Here is the caller graph for this function:


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