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

From: Nick Copeland <nickycopeland@email-addr-hidden>
Date: Thu Dec 15 2011 - 01:05:57 EET

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

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Thu Dec 15 00:15:03 2011

This archive was generated by hypermail 2.1.8 : Thu Dec 15 2011 - 00:15:03 EET