LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Can thread safe queue be used to contain srings of different sizes?

I have a thread that is writing to the queue strings of different sizes.

How do I use:
CmtNewTSQ
CmtInstallTSQCallback
CmtReadTSQData
CmtWriteTSQData

or any other ways so that another thread can read out from the queue these strings accordingly?

Thanks
0 Kudos
Message 1 of 2
(3,167 Views)
There are several ways to do this, all of which are listed in the function panel help. If you go to the CmtNewTSQ function panel and right click on the Item Size argument it gives you the options. The best option for strings is probably to treat the TSQ as a byte stream. Set the size to 1 and write the data accordingly. I.E.

char buffer1[100];
char buffer2[200];

CmtNewTSQ(1000, 1, 0, &tsqHandle);
.
.
.
CmtWriteTSQData(tsqHandle, buffer1, 100, TSQ_INFINITE_TIMEOUT, NULL);
.
CmtWriteTSQData(tsqHandle, buffer2, 200, TSQ_INFINITE_TIMEOUT, NULL);

You can also make a TSQ of pointers and always write a pointer to the string to the queue, but then you have to make sure the memory doesn't change before it is read off.

Best Regards,

Chris Matthews
Measurement Studi
o Support Manager
Message 2 of 2
(3,167 Views)