Skip to content

A shim mode for targets without threading support #861

@RReverser

Description

@RReverser

Maybe I haven't looked through issues closely enough, so apologies if this was brought up before.

One thing that comes up often when using Rayon is making sure that code works correctly on targets without threading support (e.g. wasm32-wasi or regular wasm32-unknown-unknown without threads support in general).

Probably the most common way to do this in a way that abstracts away platform differences is to build custom shim for the used rayon APIs that uses regular Iterator instead and expose it as mod rayon that will be included instead of rayon crate when corresponding feature is disabled (e.g. 1, 2, 3, 4).

However, Rayon itself feels like a lot more appropriate place for such shimming, since it has more control over APIs and would be easier to maintain than custom shims in each separate app that wants to build Rayon-dependant code in a cross-platform manner.

So, the question is: how realistic would it be to make Rayon use regular Iterators when a corresponding Cargo feature is enabled? Given that Rayon can already handle RAYON_NUM_THREADS=1 case, and the behaviour should be pretty similar, it seems doable but I'm not familiar with internals enough to estimate amount of work this would take.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions