Skip to content
This repository was archived by the owner on Oct 30, 2019. It is now read-only.

Commit c50e260

Browse files
committed
cargo fmt
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
1 parent b784e74 commit c50e260

File tree

5 files changed

+43
-42
lines changed

5 files changed

+43
-42
lines changed

benches/baseline.rs

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ mod baseline {
5959
fn spawn_many(b: &mut test::Bencher) {
6060
b.iter(|| {
6161
executor::block_on(async {
62-
let tasks = (0..25_000)
63-
.map(|_| spawn(async {}))
64-
.collect::<Vec<_>>();
62+
let tasks = (0..25_000).map(|_| spawn(async {})).collect::<Vec<_>>();
6563

6664
for task in tasks {
6765
await!(task);
@@ -78,42 +76,41 @@ mod baseline {
7876
use tokio::reactor::Registration;
7977
b.iter(|| {
8078
executor::block_on(async {
81-
let tasks = (0..300)
82-
.map(|_| {
83-
spawn(async {
84-
let (r, s) = mio::Registration::new2();
85-
let registration = Registration::new();
86-
registration.register(&r).unwrap();
87-
88-
let mut depth = 0;
89-
let mut capture = Some(r);
90-
91-
spawn(
92-
Compat01As03::new(future::poll_fn(move || loop {
93-
if registration.poll_read_ready().unwrap().is_ready() {
94-
depth += 1;
95-
if depth == 300 {
96-
capture.take().unwrap();
97-
return Ok(Async::Ready(()));
98-
}
99-
} else {
100-
s.set_readiness(mio::Ready::readable()).unwrap();
101-
return Ok(Async::NotReady);
102-
}
103-
}))
104-
.map(|_: Result<(), ()>| ()),
105-
)
106-
})
107-
})
108-
.collect::<Vec<_>>();
109-
110-
for task in tasks {
111-
await!(task);
112-
}
79+
let tasks = (0..300)
80+
.map(|_| {
81+
spawn(async {
82+
let (r, s) = mio::Registration::new2();
83+
let registration = Registration::new();
84+
registration.register(&r).unwrap();
85+
86+
let mut depth = 0;
87+
let mut capture = Some(r);
88+
89+
spawn(
90+
Compat01As03::new(future::poll_fn(move || loop {
91+
if registration.poll_read_ready().unwrap().is_ready() {
92+
depth += 1;
93+
if depth == 300 {
94+
capture.take().unwrap();
95+
return Ok(Async::Ready(()));
96+
}
97+
} else {
98+
s.set_readiness(mio::Ready::readable()).unwrap();
99+
return Ok(Async::NotReady);
100+
}
101+
}))
102+
.map(|_: Result<(), ()>| ()),
103+
)
104+
})
105+
})
106+
.collect::<Vec<_>>();
107+
108+
for task in tasks {
109+
await!(task);
110+
}
113111
})
114112
});
115-
}
116-
113+
}
117114

118115
/// Spawn function for juliex to get back a handle
119116
pub fn spawn<F, T>(fut: F) -> JoinHandle<T>

runtime-raw/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Types for defining custom [Runtime](https://github.com/rustasync/runtime)s. See the
22
//! [Runtime](https://docs.rs/runtime) documentation for more details.
3-
//!
3+
//!
44
//! These types are only necessary when implementing custom runtimes. If you're only trying to
55
//! perform IO, then there's no need to bother with any of these types as they will have been
66
//! implemented for you already.

runtime-raw/src/tcp.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ pub trait TcpListener: Debug + Send {
4040
fn local_addr(&self) -> io::Result<SocketAddr>;
4141

4242
/// Check if the listener is ready to accept connections.
43-
fn poll_accept(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<Pin<Box<dyn TcpStream>>>>;
43+
fn poll_accept(
44+
self: Pin<&mut Self>,
45+
cx: &mut Context<'_>,
46+
) -> Poll<io::Result<Pin<Box<dyn TcpStream>>>>;
4447

4548
/// Extracts the raw file descriptor.
4649
#[cfg(unix)]

src/net/tcp.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,9 @@ impl AsyncWrite for TcpStream {
219219
pub struct Connect {
220220
addrs: Option<io::Result<VecDeque<SocketAddr>>>,
221221
last_err: Option<io::Error>,
222-
future:
223-
Option<Pin<Box<dyn Future<Output = io::Result<Pin<Box<dyn runtime_raw::TcpStream>>>> + Send>>>,
222+
future: Option<
223+
Pin<Box<dyn Future<Output = io::Result<Pin<Box<dyn runtime_raw::TcpStream>>>> + Send>>,
224+
>,
224225
runtime: &'static dyn runtime_raw::Runtime,
225226
}
226227

src/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::pin::Pin;
44

55
use futures::future::FutureObj;
66
use futures::prelude::*;
7-
use futures::task::{Poll, Context};
7+
use futures::task::{Context, Poll};
88

99
/// Spawn a future on the runtime's thread pool.
1010
///

0 commit comments

Comments
 (0)