Threaded Producer-Consumer IO x86



I was playing with shared mutability and raw pointers in rust and decided to write a tiny poc of multi-threaded producer/consumer pattern. So I did. Maybe somebody finds this code helpful:

The contains the actual implementation and the show the sample usage, there is also a script that I used to test reading - writing. I’ve tested this code on Linux, Fedora 23.

The idea is to use shared mutable buffer and have two objects “Reader” and “Writer” that can access it. “Writer” is data producer, it reads data from a given input (Read implementor) and stores it into memory. “Reader” reads data from the memory. I didn’t implement any type of signaling between “Reader” - “Writer” as it was not part of an exercise, plus it could be easily done on the outside.

Also as I am very new to Rust, I am not sure that my code follows the best principles and I would appreciate any comments.

Thank you.