Now I have done this function to do it, you surely can do it better with extended error detection.
void CmtWriteTSQDataInFirstPosition(CmtTSQHandle Queue_Handle, const void *Buffer, size_t Number_of_Items, int Timeout_ms, int *Number_of_Items_Flushed)
{
CmtTSQHandle Queue_Handle_Temp = {0};
const void *BufferTemp = {0};
size_t ItemsInQueue = {0};
size_t ItemsSize = {0};
CmtGetTSQAttribute (Queue_Handle, ATTR_TSQ_ITEMS_IN_QUEUE, &ItemsInQueue);
CmtGetTSQAttribute (Queue_Handle, ATTR_TSQ_ITEM_SIZE, &ItemsSize);
CmtNewTSQ(ItemsInQueue + Number_of_Items, ItemsSize, 0, &Queue_Handle_Temp);
CmtWriteTSQData (Queue_Handle_Temp, Buffer, Number_of_Items, Timeout_ms, NULL);
BufferTemp = calloc(ItemsInQueue, ItemsSize);
while(ItemsInQueue > 0)
{
int CmtStatusOrItemRead = {0};
CmtStatusOrItemRead = CmtReadTSQData (Queue_Handle, BufferTemp, ItemsInQueue, 0, 0);
CmtWriteTSQData (Queue_Handle_Temp, BufferTemp, CmtStatusOrItemRead, Timeout_ms, NULL);
ItemsInQueue -= CmtStatusOrItemRead;
}
free(BufferTemp);
BufferTemp = 0;
CmtGetTSQAttribute (Queue_Handle_Temp, ATTR_TSQ_ITEMS_IN_QUEUE, &ItemsInQueue);
CmtGetTSQAttribute (Queue_Handle_Temp, ATTR_TSQ_ITEM_SIZE, &ItemsSize);
BufferTemp = calloc(ItemsInQueue, ItemsSize);
while(ItemsInQueue > 0)
{
int CmtStatusOrItemRead = {0};
CmtStatusOrItemRead = CmtReadTSQData (Queue_Handle_Temp, BufferTemp, ItemsInQueue, 0, 0);
CmtWriteTSQData (Queue_Handle, BufferTemp, CmtStatusOrItemRead, Timeout_ms, Number_of_Items_Flushed);
ItemsInQueue -= CmtStatusOrItemRead;
}
free(BufferTemp);
BufferTemp = 0;
return;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.