• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by John Dev


01 Dec, 2024

Updated at 02 Dec, 2024

`channel<Vec<u8>>` or `Arc<Mutex<Vec<u8>>>>` multithread program

Hi.

I want to write codes with this approach:

  1. 2 threads read compressed files(decompression takes long time).
  2. 1 consumer does something with read data.

I asked my problem to chatGPT, and he recommended Arc<Mutex<Vec<u8>>> instead of channel<Vec<u8>>

Is it right? or should I benchmark first? or.. better idea for this?

I have no idea which has more overhead, making a new vector per sending or runtime mutability checking.

Thanks in advance.

1 post - 1 participant

Read full topic