japaric-archived / linalg.rs

[INACTIVE]
Apache License 2.0
29 stars 1 forks source link

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

Open japaric opened 9 years ago

japaric commented 9 years ago
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:

japaric commented 9 years ago

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