Skip to content

Commit afca27a

Browse files
authored
Merge pull request #53 from expenses/fix-wasm
Fix wasm, add wasm ci check, move files around to distinguish native and wasm code.
2 parents f5eab47 + 9e33926 commit afca27a

File tree

11 files changed

+38
-24
lines changed

11 files changed

+38
-24
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,14 @@ jobs:
6262
git -c user.name='ci' -c user.email='ci' commit -m 'Deploy futures-timer API documentation'
6363
git push -f -q https://git:${{ secrets.github_token }}@github.com/${{ github.repository }} HEAD:gh-pages
6464
if: github.event_name == 'push' && github.event.ref == 'refs/heads/master' && github.repository == 'async-rs/futures-timer'
65+
66+
check_wasm:
67+
name: Check Wasm
68+
needs: [test]
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@master
72+
- name: Install Rust and add wasm target
73+
run: rustup update stable && rustup target add wasm32-unknown-unknown
74+
- name: cargo check
75+
run: cargo check --target wasm32-unknown-unknown --features wasm-bindgen

src/lib.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,12 @@
1616
#![deny(missing_docs)]
1717
#![warn(missing_debug_implementations)]
1818

19-
mod arc_list;
20-
mod atomic_waker;
2119
#[cfg(not(all(target_arch = "wasm32", feature = "wasm-bindgen")))]
22-
mod delay;
20+
mod native;
2321
#[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
24-
mod delay_wasm;
25-
mod global;
26-
mod heap;
27-
mod heap_timer;
28-
mod timer;
29-
30-
use arc_list::{ArcList, Node};
31-
use atomic_waker::AtomicWaker;
32-
use heap::{Heap, Slot};
33-
use heap_timer::HeapTimer;
34-
use timer::{ScheduledTimer, Timer, TimerHandle};
22+
mod wasm;
3523

3624
#[cfg(not(all(target_arch = "wasm32", feature = "wasm-bindgen")))]
37-
pub use self::delay::Delay;
25+
pub use self::native::Delay;
3826
#[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
39-
pub use self::delay_wasm::Delay;
27+
pub use self::wasm::Delay;

src/native.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
mod arc_list;
2+
mod atomic_waker;
3+
mod delay;
4+
mod global;
5+
mod heap;
6+
mod heap_timer;
7+
mod timer;
8+
9+
use self::arc_list::{ArcList, Node};
10+
use self::atomic_waker::AtomicWaker;
11+
use self::heap::{Heap, Slot};
12+
use self::heap_timer::HeapTimer;
13+
use self::timer::{ScheduledTimer, Timer, TimerHandle};
14+
15+
pub use self::delay::Delay;
File renamed without changes.
File renamed without changes.

src/delay.rs renamed to src/native/delay.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use std::sync::{Arc, Mutex};
1212
use std::task::{Context, Poll};
1313
use std::time::{Duration, Instant};
1414

15-
use crate::arc_list::Node;
16-
use crate::AtomicWaker;
17-
use crate::{ScheduledTimer, TimerHandle};
15+
use super::arc_list::Node;
16+
use super::AtomicWaker;
17+
use super::{ScheduledTimer, TimerHandle};
1818

1919
/// A future representing the notification that an elapsed duration has
2020
/// occurred.

src/global.rs renamed to src/native/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::thread;
99
use std::thread::Thread;
1010
use std::time::Instant;
1111

12-
use crate::{Timer, TimerHandle};
12+
use super::{Timer, TimerHandle};
1313

1414
pub struct HelperThread {
1515
thread: Option<thread::JoinHandle<()>>,
File renamed without changes.

src/heap_timer.rs renamed to src/native/heap_timer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::cmp::Ordering;
22
use std::sync::Arc;
33
use std::time::Instant;
44

5-
use crate::{Node, ScheduledTimer};
5+
use super::{Node, ScheduledTimer};
66

77
/// Entries in the timer heap, sorted by the instant they're firing at and then
88
/// also containing some payload data.

src/timer.rs renamed to src/native/timer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use std::time::Instant;
99

1010
use std::future::Future;
1111

12-
use crate::AtomicWaker;
13-
use crate::{global, ArcList, Heap, HeapTimer, Node, Slot};
12+
use super::AtomicWaker;
13+
use super::{global, ArcList, Heap, HeapTimer, Node, Slot};
1414

1515
/// A "timer heap" used to power separately owned instances of `Delay`.
1616
///

src/delay_wasm.rs renamed to src/wasm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Delay {
2323
/// Resets the timeout.
2424
#[inline]
2525
pub fn reset(&mut self, dur: Duration) {
26-
*self = Delay::new(at);
26+
*self = Delay::new(dur);
2727
}
2828
}
2929

0 commit comments

Comments
 (0)