Quark  0.1
AsyncQueue< T > Class Template Reference

An asynchronous queue which can be accessed from multiple threads in a threadsafe way. More...

#include <AsyncQueue.h++>

Inheritance diagram for AsyncQueue< T >:

Public Member Functions

 AsyncQueue (uint capacity)
 Constructs a new AsyncQueue with the given maximum capacity. More...
 
 ~AsyncQueue ()
 Destructor. More...
 
void offer (T *item)
 Offers an item to the queue. More...
 
T * take (int timeout=-1)
 Removes an item from the head of the queue. More...
 
void clear ()
 Clears the queue. More...
 

Detailed Description

template<typename T>
class quark::util::AsyncQueue< T >

An asynchronous queue which can be accessed from multiple threads in a threadsafe way.

Template Parameters
TThe type of object held by this queue.

Constructor & Destructor Documentation

◆ AsyncQueue()

AsyncQueue ( uint  capacity)

Constructs a new AsyncQueue with the given maximum capacity.

◆ ~AsyncQueue()

~AsyncQueue ( )

Destructor.

Member Function Documentation

◆ clear()

void clear ( )

Clears the queue.

◆ offer()

void offer ( T *  item)

Offers an item to the queue.

If the queue is currently at maximum capacity, the call blocks until there is room. The item is added at the end of the queue.

Parameters
itemThe item to enqueue.

◆ take()

T* take ( int  timeout = -1)

Removes an item from the head of the queue.

If the queue is currently empty, the call blocks until an item is available or the timeout expires. The item is removed from the head of the queue.

Parameters
timeoutThe timeout, in milliseconds, or -1 to wait indefinitely.
Returns
The item, or NULL if the timeout expired.

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