Open rts-gordon opened 3 years ago
If that for
loop is using a normal Iterator
for the Kafka data, then you can use ParallelBridge
like:
your_iterator.par_bridge().for_each(|item| {
// parallel work
});
Another option is to keep your current loop and spawn
your CPU-intensive work into Rayon, either static rayon::spawn
or within a rayon::scope
.
I will try these options, thanks a lot for your help. @cuviper
Hi there, Rayon is a great product for parallel computing. I use Kafka as an unbound data source, read Kafka data with "for loop", so I can't use Rayon function sucha s par_iter for parallel computing. Would you like to give me some examples with Rayon::par_iter to read data from Kafka? Thank you very much.
Regards CHCP