Skip to content

Commit

Permalink
Reproduction of excessive tokio polling
Browse files Browse the repository at this point in the history
With this change the reflect example will demonstrate excessive polling
in the operations task despite not being woken.
  • Loading branch information
lookback-hugotunius committed Sep 6, 2022
1 parent b43e05b commit 5d05b88
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ repository = "https://github.com/webrtc-rs/examples"

[dev-dependencies]
webrtc = { path = "../webrtc" }

tokio = { version = "1.15", features = ["full"] }
console-subscriber = { version = "<=0.1.7" }
tokio = { version = "1.15", features = ["full", "tracing"] }
env_logger = "0.9"
clap = "3.0"
hyper = { version = "0.14", features = ["full"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/reflect/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async fn main() -> Result<()> {
.filter(None, log::LevelFilter::Trace)
.init();
}

console_subscriber::init();
// Everything below is the WebRTC-rs API! Thanks for using it ❤️.

// Create a MediaEngine object to configure the supported codec
Expand Down
17 changes: 10 additions & 7 deletions webrtc/src/peer_connection/operation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,19 @@ impl Operations {
_ = close_rx.recv() => {
break;
}
result = ops_rx.recv() => {
if let Some(mut f) = result {
length.fetch_sub(1, Ordering::SeqCst);
if f.0().await {
// Requeue this operation
let _ = Operations::enqueue_inner(f, &ops_tx, &length);
}
Some(mut f) = ops_rx.recv() => {
length.fetch_sub(1, Ordering::SeqCst);
let op = format!("{:?}", f);
log::info!("Started operation {}", op);
if f.0().await {
// Requeue this operation
log::info!("Re-queued operation {}", op);
let _ = Operations::enqueue_inner(f, &ops_tx, &length);
}
log::info!("Done with operation {}", op);
}
}
log::info!("Operation loop spun");
}
}

Expand Down

0 comments on commit 5d05b88

Please sign in to comment.