Skip to content

Conversation

@gaumut
Copy link

@gaumut gaumut commented Dec 3, 2025

Closes #1548

@gaumut
Copy link
Author

gaumut commented Dec 5, 2025

Switching the Sync impl from ArrayParts to ArrayRef should allow this to pass the tests.

@nilgoyette
Copy link
Collaborator

@akern40 ArrayRef is your work. You're the best person around to know if we actually need this change.

I'm really surprised that this bug didn't appear during your refactor. We have plenty of parallel code and tests in this repo.

@gaumut
Copy link
Author

gaumut commented Dec 5, 2025

I’m not that surprised that it didn’t show up because while it doesn’t prevent this

fn test1(a: &ArrayRef1<f64>) { // works
    Zip::from(a).par_for_each(|v| {
        let _ = v;
    });
}

it does prevent doing this (which is much less common)

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

My rational is that since both of those examples work with ArrayView (I guess because ArrayView inherit the Sync impl from ArrayBase) this should also work with ArrayRef.

@gaumut
Copy link
Author

gaumut commented Dec 5, 2025

Also I saw that Send is implemented on ArrayBase, if this PR is accepted maybe Send should also be implemented on ArrayRef.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Access to &ArrayRef from multiple threads

2 participants