async-rs / async-rs/parallel-stream

Requiring `T` to be `Sync` prevents use cases that work with `task:spawn`

Open
#17 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
96
Forks
13
PR merge metrics
No merged PRs in 30d

Description

I am wondering why `ParallelStream` requires `T` to be `Sync` where `async_std::task::spawn` requires the spawned future only to be `Send + 'static`.

I ran into this issue when trying to convert some code that executes the elements of a `Stream` in parallel using `task::spawn` directly + `buffer_unordered`.

The `Stream` is `Send + 'static` but not `Sync` and therefore I cannot convert it into a `ParallelStream`. Why does it need the `T` to be thread safe? It shouldn't be shared across the tasks, does it?

Trying to use it with [this](https://docs.rs/sqlx/0.4.0-beta.1/sqlx/trait.Executor.html#method.fetch) stream.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.