> My DataMessage structure is just a simple C structure for now. Is there a<br>
> recommended way of writing it to the ringbuffer given that I want to do<br>
> something like this:<br>
><br>
> void MessageQueue::push( DataMessage msg ){<br>
>     // write to the ring buffer, converting DataMessage to a string<br>
>     unsigned int written = jack_ringbuffer_write( mRingBuffer, (char *) &msg<br>
> , sizeof(DataMessage) );<br>
>    // etc<br>
> }<br>
<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">as long as the struct is POD (Plain Old Data - no embedded pointers,<br>
etc), this will work fine.<br>
<br>
however, you need to keep in mind that under some easily encounterable<br>
circumstances, the write may not return sizeof(DataMessage). this is a<br>
very easy mistake to make with ringbuffers (ditto for read).<br>
<br>
it can be avoided via careful sizing of the ringbuffer and always<br>
read/writing "whole objects" OR by carefully checking the results of<br>
read/write.<br></blockquote><div><br></div><div>Thanks for the tips. What should one do if one detects a partial write? Is it best to have integrity checks on both ends of the ringbuffer?</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

the jack ringbuffer design is particular bad in this respect because<br>
it can only hold size-1 bytes (where size is its actual size).<br></blockquote><div><br></div><div>Does this mean a good way to initialize it is to make the ringbuffer some multiple of the sizeof(myMessageStruct) plus one byte?</div>
<div><br></div><div>Thanks again for all the help.</div><div>iain</div><div><br></div></div>