I understand, that having simultaneous read and write to the same memory is 'insta-UB' in Rust, but my domain is asking for it. I want to have a shared buffer, where one thread is writing (and reading), and other is reading disregarding the state of the writer.
What I do is 'image rendering', which can take arbitrary time, and I want to show progress (the work done insofar), without incurring atomic overhead. It's done in a fixed-size buffer.
My idea is to have two threads, one is a pure math, writing and calculating at max speed, second is 'drawing' thread, which just copy to window canvas whatever is available in a buffer now. Buffer is preinitialized by '0' (black with 0 alpha), and it's perfectly fine to have few pixels been 'outdated', and none of the possible data races can hurt.
How can this be done in Rust? This kind of 'forbidden sharing' between threads? Should I try to write it myself or there are libraries for that?