Skip to content

Access to &ArrayRef from multiple threads #1548

@gaumut

Description

@gaumut

I’m currently updating my code to the new ArrayRef type and I have some problem with access to &ArrayRef from multiple threads (see example below).

use ndarray::Zip;
use ndarray::prelude::*;

fn test_ref(a: &ArrayRef1<f64>) { // does not compile
    let b = array![0.];
    Zip::from(&b).par_for_each(|_| {
        let _ = a[0];
    });
}

fn test_view(a: &ArrayView1<f64>) { // works
    let b = array![0.];
    Zip::from(&b).par_for_each(|_| {
        let _ = a[0];
    });
}

fn main() {
    let a = array![1.];
    test_view(&a.view());
    test_ref(&a);
}

Attached is the error I get.

error.log

Is this expected ? Should I stick to ArrayView for those function ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions