Stack Class Reference

Manage a thread-safe stack of objects through reference pointers. More...

#include <containers.h>

Inheritance diagram for Stack:
Inheritance graph
[legend]
Collaboration diagram for Stack:
Collaboration graph
[legend]

Public Member Functions

size_t count (void)
 Get number of object points currently in the stack.
ObjectProtocol * get (unsigned offset=0)
 Examine an existing object on the stack.
const ObjectProtocol * peek (timeout_t timeout=0)
ObjectProtocol * pull (timeout_t timeout=0)
 Get and remove last object pushed on the stack.
bool push (ObjectProtocol *object, timeout_t timeout=0)
 Push an object into the stack by it's pointer.
bool remove (ObjectProtocol *object)
 Remove a specific object pointer for the queue.
 Stack (mempager *pager=NULL, size_t number=0)
 Create a stack that uses a memory pager for internally managed member objects for a specified maximum number of object pointers.
virtual ~Stack ()
 Destroy queue.

Protected Member Functions

virtual ObjectProtocol * invalid (void) const

Protected Attributes

size_t limit

Friends

class member

Detailed Description

Manage a thread-safe stack of objects through reference pointers.

This Thread-safe access is managed through a conditional. This differs from the queue in lifo mode because delinking the last object is immediate, and because it has much less overhead. A pool of self-managed member objects are used to operate the stack.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 310 of file containers.h.


Constructor & Destructor Documentation

Stack::Stack ( mempager pager = NULL,
size_t  number = 0 
)

Create a stack that uses a memory pager for internally managed member objects for a specified maximum number of object pointers.

Parameters:
pager to use for internal member object or NULL to use heap.
number of pointers that can be in the stack or 0 if unlimited.
virtual Stack::~Stack (  )  [virtual]

Destroy queue.

If no pager is used, then frees heap.


Member Function Documentation

size_t Stack::count ( void   ) 

Get number of object points currently in the stack.

Returns:
number of objects in stack.
ObjectProtocol* Stack::get ( unsigned  offset = 0  ) 

Examine an existing object on the stack.

Parameters:
offset to stack entry.
Returns:
object examined.
ObjectProtocol* Stack::pull ( timeout_t  timeout = 0  ) 

Get and remove last object pushed on the stack.

This can wait for a specified timeout of the stack is empty. The object is still retained and must be released or deleted by the receiving function.

Parameters:
timeout to wait if empty in milliseconds.
Returns:
object pulled from stack or NULL if empty and timed out.

Reimplemented in stackof< T >.

bool Stack::push ( ObjectProtocol *  object,
timeout_t  timeout = 0 
)

Push an object into the stack by it's pointer.

This can wait for a specified timeout if the stack is full, for example, for another thread to remove an object pointer. This also retains the object.

Parameters:
object to push.
timeout to wait if stack is full in milliseconds.
Returns:
true if object pushed, false if stack full and timeout expired.
bool Stack::remove ( ObjectProtocol *  object  ) 

Remove a specific object pointer for the queue.

This can remove a member from any location in the queue, whether beginning, end, or somewhere in the middle. This also releases the object.

Parameters:
object to remove.
Returns:
true if object was removed, false if not found.

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

Generated on 24 Sep 2014 for ucommon by  doxygen 1.6.1