Threads in Rust: Parallel Computing

แชร์
ฝัง

ความคิดเห็น • 9

  • @TRINCHIKA
    @TRINCHIKA 24 วันที่ผ่านมา +2

    Cool channel, useful information.

  • @cobbcoding
    @cobbcoding 29 วันที่ผ่านมา

    best rust channel on youtube

  • @griffinmartin6356
    @griffinmartin6356 27 วันที่ผ่านมา +2

    uses rwlock and proceeds to only use the write portion of it.
    you should've grabbed a read first and checked if the number was larger. if it was then you grab a write and write to that number if it isn't then you never grab a write

    • @rustwithoutrust
      @rustwithoutrust  27 วันที่ผ่านมา

      Right, that wasn't the cleanest way. Actually, thought about it 😅
      Great you've noticed that!
      Edit: No, you actually can't do it, because you can't lock twice at the same time.

    • @kevz3351
      @kevz3351 26 วันที่ผ่านมา

      that wouldn’t work since it will cause data races, another thread could occupy it when you were going to grab a write.

    • @griffinmartin6356
      @griffinmartin6356 26 วันที่ผ่านมา

      @@kevz3351 your right. in this case RwLock does not help

    • @rustwithoutrust
      @rustwithoutrust  26 วันที่ผ่านมา

      ​@@kevz3351You guys are getting me confused now 🤔 Lemme see who's right later for myself.