Skip to content

Commit 11baa0e

Browse files
committed
Switch to wasm-timer for Instant, don't use parking_lot
1 parent 0ca73c2 commit 11baa0e

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ Timeouts for futures.
1515
[dependencies]
1616

1717
[target.wasm32-unknown-unknown.dependencies]
18-
instant = { version = "0.1.2", features = ["wasm-bindgen"] }
18+
wasm-timer = "0.2.4"
1919
wasm-bindgen = "0.2.55"
2020
futures = "0.3.1"
2121
web-sys = "0.3.32"
22-
parking_lot = "0.10.0"
2322

2423
[dev-dependencies]
2524
async-std = { version = "1.0.1", features = ["attributes"] }

src/global_wasm.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use futures::task::{self, ArcWake};
2-
use parking_lot::Mutex;
2+
use std::sync::Mutex;
33
use std::convert::TryFrom;
44
use std::future::Future;
55
use std::pin::Pin;
@@ -26,10 +26,10 @@ pub(crate) fn run() -> TimerHandle {
2626
/// processes everything.
2727
fn schedule_callback(timer: Arc<Mutex<Timer>>, when: Duration) {
2828
let window = web_sys::window().expect("Unable to access Window");
29-
let _ = window
29+
window
3030
.set_timeout_with_callback_and_timeout_and_arguments_0(
3131
&Closure::once_into_js(move || {
32-
let mut timer_lock = timer.lock();
32+
let mut timer_lock = timer.lock().unwrap();
3333

3434
// We start by polling the timer. If any new `Delay` is created, the waker will be used
3535
// to wake up this task pre-emptively. As such, we pass a `Waker` that calls

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ use timer::{ScheduledTimer, Timer, TimerHandle};
3535

3636
pub use self::delay::Delay;
3737
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
38-
use instant::Instant;
38+
use wasm_timer::Instant;
3939
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
4040
use std::time::Instant;

0 commit comments

Comments
 (0)