Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Can't send mutable blocks of a matrix to scoped threads #66

Open
japaric opened this issue May 6, 2015 · 1 comment
Open

Can't send mutable blocks of a matrix to scoped threads #66

japaric opened this issue May 6, 2015 · 1 comment

Comments

@japaric
Copy link
Contributor

japaric commented May 6, 2015

fn fork_join(mut A: Mat<f64>) {
    let mut guards = vec![];

    for stripe in A.hstripes_mut(100) {
        for block in stripe.vstripes_mut(100) {
            //~^ error: `stripe` does not live long enough
            guards.push(thread::scoped(|| { block; }));
        }
    }
}

The problem is the signature of iter_mut, it borrows the sub-matrix rather than re-borrowing the original data. Two ways to fix this:

  • Add user-defined unsized types to get proper re-borrow semantics.
  • Change the signature of iter_mut (and several other similar functions) to take the caller by value.
@japaric japaric added the bug label May 6, 2015
@japaric
Copy link
Contributor Author

japaric commented May 6, 2015

Actually this also happens with immutable blocks of memory, but I think that's easier to fix.

@japaric japaric added the tedious label May 6, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant