Table_generator.generate_parallel cannot be accessed by multiple threads

In TableGenerator , there is a method called generate_parallel . Why is this method not allowed to be accessed in a multi-threaded environment? I’m very curious about this issue. How can it be modified to be used in a multi-threaded context, especially for read-only operations?

It takes &mut self, this is basic Rust. You can wrap it in Mutex, but you’ll still be able to use it from one thread at a time or else the code will be unsound.

Using generate_parallel for read-only operations makes no sense since it does mutation internally.

I find that the scope of the Mutex lock is too large. I want to achieve as much parallel access as possible with generate_parallel , but I can’t seem to find the specific implementation of generate_parallel . Why might this be? Also, if I use generate_parallel in parallel, could it lead to failures?

You can’t run unsound code in Rust by design. If you want to run generate_parallel multiple times concurrently you to create multiple instances of TableGenerator. There are already examples of this in the code of the farmer.

Can multiple TableGenerators produce the same results under the same Seed conditions?

They 100% will, otherwise the protocol is fundamentally broken