Don't implement Send at all

On hosted platforms, libstd allows safely borrowing values from TLS with
'thread lifetime and without a Sync bound. As a result, we can't
guarantee that sending a generator across threads won't create dangling
references or data races. In freestanding environments, the notion of
thread-safety is likely to be defined by the consumer of libfringe,
so our Send bounds and implementation are unlikely to be meaningful
anyway.
This commit is contained in:
edef 2017-03-05 20:19:42 +01:00
parent 34ab0dc2cd
commit 661872f725
2 changed files with 2 additions and 7 deletions

View File

@ -88,9 +88,6 @@ pub struct Generator<'a, Input: 'a, Output: 'a, Stack: stack::Stack> {
phantom: PhantomData<(&'a (), *mut Input, *const Output)> phantom: PhantomData<(&'a (), *mut Input, *const Output)>
} }
unsafe impl<'a, Input, Output, Stack> Send for Generator<'a, Input, Output, Stack>
where Input: Send + 'a, Output: Send + 'a, Stack: stack::Stack + Send {}
impl<'a, Input, Output, Stack> Generator<'a, Input, Output, Stack> impl<'a, Input, Output, Stack> Generator<'a, Input, Output, Stack>
where Input: 'a, Output: 'a, Stack: stack::Stack { where Input: 'a, Output: 'a, Stack: stack::Stack {
/// Creates a new generator. /// Creates a new generator.
@ -98,7 +95,7 @@ impl<'a, Input, Output, Stack> Generator<'a, Input, Output, Stack>
/// See also the [contract](../trait.GuardedStack.html) that needs to be fulfilled by `stack`. /// See also the [contract](../trait.GuardedStack.html) that needs to be fulfilled by `stack`.
pub fn new<F>(stack: Stack, f: F) -> Generator<'a, Input, Output, Stack> pub fn new<F>(stack: Stack, f: F) -> Generator<'a, Input, Output, Stack>
where Stack: stack::GuardedStack, where Stack: stack::GuardedStack,
F: FnOnce(&Yielder<Input, Output>, Input) + Send + 'a { F: FnOnce(&Yielder<Input, Output>, Input) + 'a {
unsafe { Generator::unsafe_new(stack, f) } unsafe { Generator::unsafe_new(stack, f) }
} }
@ -110,7 +107,7 @@ impl<'a, Input, Output, Stack> Generator<'a, Input, Output, Stack>
/// ///
/// See also the [contract](../trait.Stack.html) that needs to be fulfilled by `stack`. /// See also the [contract](../trait.Stack.html) that needs to be fulfilled by `stack`.
pub unsafe fn unsafe_new<F>(stack: Stack, f: F) -> Generator<'a, Input, Output, Stack> pub unsafe fn unsafe_new<F>(stack: Stack, f: F) -> Generator<'a, Input, Output, Stack>
where F: FnOnce(&Yielder<Input, Output>, Input) + Send + 'a { where F: FnOnce(&Yielder<Input, Output>, Input) + 'a {
unsafe extern "C" fn generator_wrapper<Input, Output, Stack, F>(env: usize, stack_ptr: StackPointer) -> ! unsafe extern "C" fn generator_wrapper<Input, Output, Stack, F>(env: usize, stack_ptr: StackPointer) -> !
where Stack: stack::Stack, F: FnOnce(&Yielder<Input, Output>, Input) { where Stack: stack::Stack, F: FnOnce(&Yielder<Input, Output>, Input) {
// Retrieve our environment from the callee and return control to it. // Retrieve our environment from the callee and return control to it.

View File

@ -87,8 +87,6 @@ fn with_owned_stack() {
fn forget_yielded() { fn forget_yielded() {
struct Dropper(*mut bool); struct Dropper(*mut bool);
unsafe impl Send for Dropper {}
impl Drop for Dropper { impl Drop for Dropper {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {