vporton
October 20, 2021, 10:49am
1
I have suggested that stdlib misses the feature to send refs to non-Send
objects between threads using mutexes and proposed a change:
unsafe impl<'mutex, T: ?Sized + Sync> Sync for Mutex<'mutex, T> {}
unsafe impl<'mutex, T: ?Sized> Send for Mutex<'mutex, T> { }
I also showed my library with class RefMutex
as a workaround.
Are my
proposed changes to stdlib
my workaround library
correct?
alice
October 20, 2021, 11:40am
2
This would let you send any value to another thread by wrapping it in a Mutex<Option<T>>
, sending the mutex to the other thread, and taking the value out of the Option
by replacing the Option
with None
.
7 Likes
(In other words, as was already pointed out in that IRLO thread, neither your proposed changes to std nor your workaround library are correct.)
system
Closed
January 18, 2022, 4:03pm
4
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.