Concurrent programming in Rust part 10

Опубликовано: 17 Сентябрь 2023
на канале: Dario
863
38

So you need to share an object between threads, what do you do?

Wrap it in an ArcMutex pointer and call it a day right?

Let's take it to the next level.

A very common pattern in rust is to hide the arc mutex pointer in an inner property and to implement the clone trait, that way you can just pass the object around by cloning it.

Just be careful, because every time you call a method in your SharedCache object you will be locking internally, which might lead to some race conditions.


На этой странице сайта вы можете посмотреть видео онлайн Concurrent programming in Rust part 10 длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Dario 17 Сентябрь 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 863 раз и оно понравилось 38 зрителям. Приятного просмотра!