New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider expert interfaces for writing to data in place #4
Comments
As pointed out by fyl2xp1, the consumer-side expert methods should tell whether the buffer has been swapped since the last time a buffer was read. This allows things like performing in-place post-processing on a value that was received from a producer, and only carrying out the post-processing again when a new value is received. |
One argument against giving write access to the consumer is that it will make the synchronization protocol more expensive on relaxed-memory architectures by requiring an AcqRel memory barrier on all writes to the back buffer info (as buffer writes now happen on both sides), where an Acquire-Release pair currently suffices. As there is a compromise between various performance characteristics (in-place writes vs efficient synchronization), the best thing to do might be to make the raw reads and writes an optional feature of the crate. |
Okay, I'll do this. There is a prototype of this approach in branch raw-read-write (https://github.com/HadrienG2/triple-buffer/tree/raw-read-write). |
Done in v1.1.0 |
As pointed out by users.rust-lang.org member fyl2xp1 in a thread about his own implementation of triple buffering, it would be nice in some cases if the producer and the consumer could overwrite their buffer, as some copies could sometimes be avoided that way.
I historically considered this option while writing triple-buffer, but ultimately decided against it at the time because it exposed some confusing aspects of the synchronization protocol to the clients:
If there is demand, I can revise my decision and integrate this feature. But it will forever remain an advanced interface for experts, alongside the current simple and easy to use interface.
The text was updated successfully, but these errors were encountered: