ucc::stack Class Reference

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

#include <thread.h>

Inheritance diagram for ucc::stack:

Inheritance graph
[legend]
Collaboration diagram for ucc::stack:

Collaboration graph
[legend]

Public Member Functions

 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.
 ~stack ()
 Destroy queue.
bool remove (Object *object)
 Remove a specific object pointer for the queue.
bool push (Object *object, timeout_t timeout=0)
 Push an object into the stack by it's pointer.
Objectpull (timeout_t timeout=0)
 Get and remove last object pushed on the stack.
size_t getCount (void)
 Get number of object points currently in the stack.

Static Public Member Functions

static bool remove (stack &stack, Object *object)
 Convenience function to remove an object from the stacl.
static bool push (stack &stack, Object *object, timeout_t timeout=0)
 Convenience function to push object into the stack.
static Objectpull (stack &stack, timeout_t timeout=0)
 Convenience function pull last object from the stack.
static size_t count (stack &stack)
 Convenience function to get count of objects in the stack.

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 1785 of file thread.h.


Constructor & Destructor Documentation

ucc::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.

ucc::stack::~stack (  ) 

Destroy queue.

If no pager is used, then frees heap.


Member Function Documentation

static size_t ucc::stack::count ( stack stack  )  [inline, static]

Convenience function to get count of objects in the stack.

Parameters:
stack to count.
Returns:
number of objects in the stack.

Definition at line 1885 of file thread.h.

Here is the call graph for this function:

size_t ucc::stack::getCount ( void   ) 

Get number of object points currently in the stack.

Returns:
number of objects in stack.

static Object* ucc::stack::pull ( stack stack,
timeout_t  timeout = 0 
) [inline, static]

Convenience function pull last object from the stack.

Parameters:
stack to get from.
timeout to wait if empty.
Returns:
last object or NULL if timed out empty.

Definition at line 1877 of file thread.h.

Here is the call graph for this function:

Object* ucc::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 ucc::stackof< T, P >.

static bool ucc::stack::push ( stack stack,
Object object,
timeout_t  timeout = 0 
) [inline, static]

Convenience function to push object into the stack.

Parameters:
stack to push into.
object to push.
timeout to wait if full.
Returns:
true if pusheded, false if timed out while full.

Definition at line 1868 of file thread.h.

Here is the call graph for this function:

bool ucc::stack::push ( Object 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.

static bool ucc::stack::remove ( stack stack,
Object object 
) [inline, static]

Convenience function to remove an object from the stacl.

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

Definition at line 1858 of file thread.h.

bool ucc::stack::remove ( Object 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 Wed May 13 08:43:21 2009 for UCommon by  doxygen 1.5.7.1