ringbuffer icon indicating copy to clipboard operation
ringbuffer copied to clipboard

Add a try_reserve_write() method to avoid extra copies on write

Open bslatkin opened this issue 8 years ago • 0 comments

The idea is you called this first and it would return a buffer for the next available slot. The reader wouldn't be able to get to this buffer yet. You'd cast the buffer as a ctypes Structure and populate it with whatever information you have. Then you'd call write_finished() on the buffer. At that point readers would then be able to read the slot.

Doing it this way would avoid the extra copy that writers do and let them directly populate the slot. The key point of this design is it would have to avoid holding the writer lock during this time. It would just prevent other readers or writers from progressing until this slot was full.

bslatkin avatar Aug 08 '16 05:08 bslatkin