Skip to content

Add embassy-time sleeper#168

Closed
wackazong wants to merge 1 commit intoXuanwo:mainfrom
wackazong:patch-2
Closed

Add embassy-time sleeper#168
wackazong wants to merge 1 commit intoXuanwo:mainfrom
wackazong:patch-2

Conversation

@wackazong
Copy link
Copy Markdown
Contributor

I added a sleeper based on the embassy framework in no_std. Also did some adjustments to fastrand since the current no_std implementation did not compile. fastrand supports no_std, but only without a global RNG.

pub use exponential::ExponentialBuilder;

#[cfg(feature = "std")]
fn f32() -> f32 {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your PR! I suggest we split this PR into two:

  • One is to make sure backon available on std
  • The other one is to add embassy_time support.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure.


#[cfg(all(not(feature = "std"), not(feature = "embassy-time")))]
fn f32() -> f32 {
fastrand::Rng::with_seed(0x2fdb0020ffc7722b).f32()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a seed option on ExponentialBuilder instead? In this way, we can avoid unexpected behavior happened.

We can't carry an Rng in builder since it doesn't copy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me.

@wackazong wackazong closed this Dec 1, 2024
Xuanwo added a commit that referenced this pull request Dec 17, 2024
Split #168 into two PRs as
requested, this is the one for no_std support.

---------

Co-authored-by: Xuanwo <github@xuanwo.io>
wackazong added a commit to wackazong/backon that referenced this pull request Dec 17, 2024
Split Xuanwo#168 into two PRs as
requested, this is the one for no_std support.

---------

Co-authored-by: Xuanwo <github@xuanwo.io>
wackazong added a commit to wackazong/backon that referenced this pull request Dec 17, 2024
Split Xuanwo#168 into two PRs as
requested, this is the one for no_std support.

---------

Co-authored-by: Xuanwo <github@xuanwo.io>
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.

2 participants