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.