Update the libraries to reflect Send loosing the 'static bound.
In most places this preserves the current API by adding an explicit `'static` bound. Notably absent are some impls like `unsafe impl<T: Send> Send for Foo<T>` and the `std::thread` module. It is likely that it will be possible to remove these after auditing the code to ensure restricted lifetimes are safe. More progress on #22251.
This commit is contained in:
parent
cae969e2a7
commit
d7b5bc3c2f
20 changed files with 83 additions and 81 deletions
|
|
@ -55,9 +55,9 @@ pub struct Packet<T> {
|
|||
lock: Mutex<State<T>>,
|
||||
}
|
||||
|
||||
unsafe impl<T:Send> Send for Packet<T> { }
|
||||
unsafe impl<T: Send + 'static> Send for Packet<T> { }
|
||||
|
||||
unsafe impl<T:Send> Sync for Packet<T> { }
|
||||
unsafe impl<T: Send + 'static> Sync for Packet<T> { }
|
||||
|
||||
struct State<T> {
|
||||
disconnected: bool, // Is the channel disconnected yet?
|
||||
|
|
@ -75,7 +75,7 @@ struct State<T> {
|
|||
canceled: Option<&'static mut bool>,
|
||||
}
|
||||
|
||||
unsafe impl<T: Send> Send for State<T> {}
|
||||
unsafe impl<T: Send + 'static> Send for State<T> {}
|
||||
|
||||
/// Possible flavors of threads who can be blocked on this channel.
|
||||
enum Blocker {
|
||||
|
|
@ -113,7 +113,7 @@ pub enum Failure {
|
|||
|
||||
/// Atomically blocks the current thread, placing it into `slot`, unlocking `lock`
|
||||
/// in the meantime. This re-locks the mutex upon returning.
|
||||
fn wait<'a, 'b, T: Send>(lock: &'a Mutex<State<T>>,
|
||||
fn wait<'a, 'b, T: Send + 'static>(lock: &'a Mutex<State<T>>,
|
||||
mut guard: MutexGuard<'b, State<T>>,
|
||||
f: fn(SignalToken) -> Blocker)
|
||||
-> MutexGuard<'a, State<T>>
|
||||
|
|
@ -136,7 +136,7 @@ fn wakeup<T>(token: SignalToken, guard: MutexGuard<State<T>>) {
|
|||
token.signal();
|
||||
}
|
||||
|
||||
impl<T: Send> Packet<T> {
|
||||
impl<T: Send + 'static> Packet<T> {
|
||||
pub fn new(cap: uint) -> Packet<T> {
|
||||
Packet {
|
||||
channels: AtomicUsize::new(1),
|
||||
|
|
@ -412,7 +412,7 @@ impl<T: Send> Packet<T> {
|
|||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl<T: Send> Drop for Packet<T> {
|
||||
impl<T: Send + 'static> Drop for Packet<T> {
|
||||
fn drop(&mut self) {
|
||||
assert_eq!(self.channels.load(Ordering::SeqCst), 0);
|
||||
let mut guard = self.lock.lock().unwrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue