Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to provide your own seed to racey futures #75

Merged
merged 3 commits into from
Sep 3, 2023

Conversation

notgull
Copy link
Member

@notgull notgull commented Aug 24, 2023

The race functions were not available on no_std targets. This commit
adds "with_seed" variants that take a u64 seed that is passed to
fastrand. It can be used on no_std targets to provide random racey
futures and streams.

A "race" feature is added that enables it. This way fastrand doesn't
become a dependency for crates that don't need it, like async-io.

As part of this change, each racy futures provides its own Rng instance.

This commit prevents these functions from needed to make calls into
thread-local storage for every poll.

Signed-off-by: John Nunley <[email protected]>
@notgull notgull requested a review from fogti September 2, 2023 20:38
Cargo.toml Outdated Show resolved Hide resolved
The race functions were not available on no_std targets. This commit
adds "with_seed" variants that take a u64 seed that is passed to
fastrand. It can be used on no_std targets to provide random racey
futures and streams.

A "race" feature is added that enables it. This way fastrand doesn't
become a dependency for crates that don't need it, like async-io.

Signed-off-by: John Nunley <[email protected]>
This prevents memchr compile errors for now.

Signed-off-by: John Nunley <[email protected]>
@notgull notgull force-pushed the notgull/efficient-rng branch from 1639427 to b85ecf5 Compare September 3, 2023 15:15
@notgull notgull merged commit 2234456 into master Sep 3, 2023
@notgull notgull deleted the notgull/efficient-rng branch September 3, 2023 15:18
@notgull notgull mentioned this pull request Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants