I propose altering the Send
trait as proposed by RFC #17 as
follows:
-
Remove the implicit
'static
bound fromSend
. -
Make
&T
Send
if and only ifT
isSync
.impl<'a, T> !Send for &'a T {}
unsafe impl<'a, T> Send for &'a T where T: Sync + 'a {}
-
Evaluate each
Send
bound currently in libstd and either leave it as-is, add an explicit 'static bound, or bound it with another lifetime parameter.
The primary motivation for this is to fix some inconsistencies with the current threading model that I believe will show up when we start writing fork-join libraries (perhaps a better term would be “bounded-lifetime threads”, since that’s the interesting part). There are some pathological types may make the Sync
bound inadequate, and there are a lot of concurrent types that currently require a 'static
bound (like Mutex
) but which I’m pretty sure could be safe to share under certain circumstances even with non-'static
references with bounded-lifetime threads.
More at the link: https://gist.github.com/pythonesque/ab744000f6c656f53b7a