formatting changes
This commit is contained in:
parent
39240b4a50
commit
ec7e40a309
1 changed files with 9 additions and 4 deletions
13
src/lib.rs
13
src/lib.rs
|
@ -11,6 +11,9 @@ use std::{
|
|||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
const PRUNE_SPAWN_COUNT: u64 = 1000;
|
||||
const PRUNE_DURATION: Duration = Duration::from_secs(5);
|
||||
|
||||
enum OneshotState<T> {
|
||||
New,
|
||||
Waker(Waker),
|
||||
|
@ -236,9 +239,6 @@ struct Inner {
|
|||
prune_time: Instant,
|
||||
}
|
||||
|
||||
const SPAWN_COUNT: u64 = 1000;
|
||||
const PRUNE_DURATION: Duration = Duration::from_secs(5);
|
||||
|
||||
impl Inner {
|
||||
fn take_available_head(&mut self) -> Option<Arc<Task>> {
|
||||
let head = self.head_available.take()?;
|
||||
|
@ -253,7 +253,8 @@ impl Inner {
|
|||
}
|
||||
|
||||
fn heuristic_prune(&mut self) {
|
||||
if self.spawn_count > SPAWN_COUNT || self.prune_time + PRUNE_DURATION < Instant::now() {
|
||||
if self.spawn_count > PRUNE_SPAWN_COUNT || self.prune_time + PRUNE_DURATION < Instant::now()
|
||||
{
|
||||
self.prune();
|
||||
}
|
||||
}
|
||||
|
@ -409,14 +410,18 @@ impl Executor {
|
|||
if let Poll::Ready(res) = Pin::new(&mut join_handle).poll(&mut block_on_context) {
|
||||
return res;
|
||||
}
|
||||
|
||||
self.heuristic_prune();
|
||||
}
|
||||
|
||||
if let Poll::Ready(res) = Pin::new(&mut join_handle).poll(&mut block_on_context) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if self.stopping() {
|
||||
return Err(JoinError);
|
||||
}
|
||||
|
||||
self.park();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue