-
Notifications
You must be signed in to change notification settings - Fork 39
Support for wasm32-unknown-unknown
#51
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
Merged
Merged
Changes from 23 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
abf64b7
Support wasm
expenses 2f1984a
Error instead
expenses 17b80a1
Revert "Error instead"
expenses 10722a7
add wasm global
expenses 979bae8
src/global.rs -> src/global_native.rs
expenses 0ca73c2
Fix tests, cargo fmt
expenses 11baa0e
Switch to wasm-timer for Instant, don't use parking_lot
expenses e394596
Fmt
expenses bfbe40d
Use feature flag instead
expenses 832cfa2
Merge remote-tracking branch 'origin/master' into wasm-support
expenses 0b5fe5e
Update Cargo.toml
expenses 00d43f3
Merge branch 'wasm-support' of github.com:expenses/futures-timer into…
expenses e8e60aa
Revert "Update Cargo.toml"
expenses ab267cc
Fix native build
expenses 94cb276
Use global_native when not on wasm32
expenses db64f45
Appease clippy a bit
expenses ae4a837
Switch to gloo-timers
expenses 2250577
Fix pinning
expenses 5ced38b
Add send_wrapper
expenses 1c66b18
Add a reset stub
expenses 2746e4d
Change reset behavious to panic
expenses 5d737ca
Remove 'when' from Delay, switch reset to take a Duration
expenses 4cf9125
run cargo fmt
expenses 034ea15
Update src/delay_wasm.rs
expenses 0190692
Update src/delay_wasm.rs
expenses 511b0a1
Update src/delay.rs
expenses ef8a441
fix clippy, nitpicks
expenses 06d1bd8
Merge branch 'wasm-support' of github.com:expenses/futures-timer into…
expenses 9f620d7
delay -> dur
expenses File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//! A version of `Delay` that works on wasm. | ||
|
||
use gloo_timers::future::TimeoutFuture; | ||
use send_wrapper::SendWrapper; | ||
use std::{ | ||
future::Future, | ||
pin::Pin, | ||
task::{Context, Poll}, | ||
time::Duration, | ||
}; | ||
|
||
/// A version of `Delay` that works on wasm. | ||
#[derive(Debug)] | ||
pub struct Delay(SendWrapper<TimeoutFuture>); | ||
|
||
impl Delay { | ||
/// Creates a new future which will fire at `dur` time into the future. | ||
#[inline] | ||
pub fn new(dur: Duration) -> Delay { | ||
Self(SendWrapper::new(TimeoutFuture::new(dur.as_millis() as u32))) | ||
} | ||
|
||
/// Resets the timeout. Panics on wasm. | ||
expenses marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[inline] | ||
pub fn reset(&mut self, at: Duration) { | ||
expenses marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*self = Delay::new(at); | ||
} | ||
} | ||
|
||
impl Future for Delay { | ||
type Output = (); | ||
|
||
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output> { | ||
Pin::new(&mut *Pin::into_inner(self).0).poll(cx) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.