Skip to content

Commit c84d578

Browse files
Remove dependency to wasm timer
1 parent 65229db commit c84d578

File tree

3 files changed

+31
-83
lines changed

3 files changed

+31
-83
lines changed

Diff for: Cargo.lock

+24-77
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: core/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ avail-rust = { workspace = true, default-features = false, features = ["wasm"] }
7676
blake2b_simd = "1.0.2"
7777
color-eyre = { workspace = true }
7878
ed25519-compact = "2.1.1"
79-
# NOTE: This is used due bug explained at: https://github.com/tomaka/wasm-timer/pull/13
80-
fluvio-wasm-timer = "0.2.5"
8179
hyper = { version = "0.14.23", features = ["http1"] }
8280
libp2p = { workspace = true, features = ["wasm-bindgen"] }
8381
libp2p-webrtc-websys = { workspace = true }

Diff for: core/src/network/p2p/event_loop.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
use color_eyre::{eyre::eyre, Result};
2-
#[cfg(target_arch = "wasm32")]
3-
use fluvio_wasm_timer::Interval;
42
use futures::StreamExt;
53
#[cfg(not(target_arch = "wasm32"))]
64
use libp2p::mdns;
@@ -205,8 +203,9 @@ impl EventLoop {
205203

206204
#[cfg(not(target_arch = "wasm32"))]
207205
let mut report_timer = interval(event_counter.report_interval);
206+
208207
#[cfg(target_arch = "wasm32")]
209-
let mut report_timer = Interval::new(event_counter.report_interval);
208+
let mut next_tick = Instant::now() + event_counter.report_interval;
210209

211210
loop {
212211
#[cfg(not(target_arch = "wasm32"))]
@@ -237,6 +236,9 @@ impl EventLoop {
237236
}
238237
}
239238

239+
#[cfg(target_arch = "wasm32")]
240+
let now = Instant::now();
241+
240242
#[cfg(target_arch = "wasm32")]
241243
tokio::select! {
242244
event = self.swarm.next() => {
@@ -253,9 +255,10 @@ impl EventLoop {
253255
break;
254256
},
255257
},
256-
_ = report_timer.next() => {
258+
_ = tokio::time::sleep(next_tick.checked_duration_since(now).unwrap_or_default()) => {
257259
debug!("Events per {}s: {:.2}", event_counter.duration_secs(), event_counter.count_events());
258260
event_counter.reset_counter();
261+
next_tick += event_counter.report_interval;
259262
},
260263
// if the shutdown was triggered,
261264
// break the loop immediately, proceed to the cleanup phase

0 commit comments

Comments
 (0)