OpenClovis Logo

API Usage Examples
Queue Library

Code Examples. More...

Code Examples.

ClRcT rc = CL_OK;
// Queue should be created before using, creating the queue of 256
// elements
rc = clQueueCreate(256, clTstEnqCallback, clTstEnqCallback,
&queueHandle)),
if( \c CL_OK != rc )
{
// Queue create failed, nothing can be done, take appropriate action
}
// add a node to the queue.
ClQueueDataT qData = YYYY; // could be simple data or complex
rc = clQueueNodeInsert(queueHandle, qData);
if(\c CL_OK != rc)
{
// error occurred. Take appropriate action
}
//the first node will be deleted and the data will be returned on the
//data
rc = clQueueNodeDelete(queueHandle, &qData);
if( \c CL_OK != rc)
{
//Error occured. Take appropriate action.
}
ClUint32T size = 0;
// Getting the size of the Queue
rc = clQueueSizeGet(queueHandle, &size);
if( \c CL_OK != rc )
{
//Error occured. Take appropriate action.
}
//Queue should be deleted during finalize of system, otherwise it may
//lead to memory leaks, for each node deletion the QueueDestroyCallback
//will be called.
rc = clQueueDelete(queueHandle);
if(\c CL_OK != rc)
{
// Error occured. Take appropriate action.
}
// to walk through all the elements on the queue, the following
// operation should be performed.
// the queuewalk callback function is getting called while walking
//through all the queue elements.
void clTstQueueWalkCb(ClQueueT qData, void *pData)
{
// Data of the walk thru node.
// Cookie of the QueueWalk function.
}
rc = clQueueWalk(queueHandle, clTstQueueWalkCb, pCookie);
if( \c CL_OK != rc )
{
// Error occured. Take appropriate action.
}

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen