[LAD] easiest way to serialize messages for sending over a ringbuffer?

Nick Copeland nickycopeland at hotmail.com
Wed Dec 14 23:05:57 UTC 2011


> if I understand what you're saying, the producer should check for sizeof(MyStruct) space before writing, 


Yes. Partial writes are possible but are going have to take care of when you write the remainder, and also cater for partial reads as well. These would introduce some ugly timing issues between producer and consumer.


> and just delay writing that message if there isn't enough space. I guess that's where I would log that there a write failed then?
Well, saying 'just' might be an understatement - there are issues here too but they should be less that writing partial structures.

There was mention of writing pointers to buffers, I would avoid this as well for the possible case that you want to mount your ringbuffers in shared memory between processes rather than between threads. It might not be your goal now but it would be painful if that changed in the future.

Regards, nick.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20111215/96826ee6/attachment.html>


More information about the Linux-audio-dev mailing list