Skip to content

Commit fc4e472

Browse files
Merge pull request #733 from k-nasa/new-scheduler
New scheduler
2 parents 6674dc0 + 088aa56 commit fc4e472

23 files changed

+568
-388
lines changed

Diff for: Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ default = [
2626
"async-task",
2727
"crossbeam-channel",
2828
"crossbeam-deque",
29+
"crossbeam-queue",
2930
"futures-timer",
3031
"kv-log-macro",
3132
"log",
@@ -58,6 +59,7 @@ async-task = { version = "1.3.1", optional = true }
5859
broadcaster = { version = "1.0.0", optional = true }
5960
crossbeam-channel = { version = "0.4.2", optional = true }
6061
crossbeam-deque = { version = "0.7.3", optional = true }
62+
crossbeam-queue = { version = "0.2.0", optional = true }
6163
crossbeam-utils = { version = "0.7.2", optional = true }
6264
futures-core = { version = "0.3.4", optional = true, default-features = false }
6365
futures-io = { version = "0.3.4", optional = true }

Diff for: src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ cfg_default! {
270270
pub mod fs;
271271
pub mod path;
272272
pub mod net;
273+
pub(crate) mod rt;
273274
}
274275

275276
cfg_unstable! {

Diff for: src/net/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,5 @@ pub use tcp::{Incoming, TcpListener, TcpStream};
6666
pub use udp::UdpSocket;
6767

6868
mod addr;
69-
pub(crate) mod driver;
7069
mod tcp;
7170
mod udp;

Diff for: src/net/tcp/listener.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::sync::Arc;
55

66
use crate::future;
77
use crate::io;
8-
use crate::net::driver::Watcher;
8+
use crate::rt::Watcher;
99
use crate::net::{TcpStream, ToSocketAddrs};
1010
use crate::stream::Stream;
1111
use crate::task::{Context, Poll};

Diff for: src/net/tcp/stream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::sync::Arc;
55

66
use crate::future;
77
use crate::io::{self, Read, Write};
8-
use crate::net::driver::Watcher;
8+
use crate::rt::Watcher;
99
use crate::net::ToSocketAddrs;
1010
use crate::task::{Context, Poll};
1111

Diff for: src/net/udp/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::net::SocketAddr;
33
use std::net::{Ipv4Addr, Ipv6Addr};
44

55
use crate::future;
6-
use crate::net::driver::Watcher;
76
use crate::net::ToSocketAddrs;
7+
use crate::rt::Watcher;
88
use crate::utils::Context as _;
99

1010
/// A UDP socket.
@@ -102,7 +102,7 @@ impl UdpSocket {
102102
/// ```no_run
103103
/// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
104104
/// #
105-
/// use async_std::net::UdpSocket;
105+
/// use async_std::net::UdpSocket;
106106
///
107107
/// let socket = UdpSocket::bind("127.0.0.1:0").await?;
108108
/// let addr = socket.local_addr()?;

Diff for: src/os/unix/net/datagram.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use mio_uds;
88
use super::SocketAddr;
99
use crate::future;
1010
use crate::io;
11-
use crate::net::driver::Watcher;
11+
use crate::rt::Watcher;
1212
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
1313
use crate::path::Path;
1414
use crate::task::spawn_blocking;

Diff for: src/os/unix/net/listener.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use super::SocketAddr;
1010
use super::UnixStream;
1111
use crate::future;
1212
use crate::io;
13-
use crate::net::driver::Watcher;
13+
use crate::rt::Watcher;
1414
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
1515
use crate::path::Path;
1616
use crate::stream::Stream;

Diff for: src/os/unix/net/stream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use mio_uds;
99

1010
use super::SocketAddr;
1111
use crate::io::{self, Read, Write};
12-
use crate::net::driver::Watcher;
12+
use crate::rt::Watcher;
1313
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
1414
use crate::path::Path;
1515
use crate::task::{spawn_blocking, Context, Poll};

Diff for: src/rt/mod.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! The runtime.
2+
3+
use std::thread;
4+
5+
use once_cell::sync::Lazy;
6+
7+
use crate::utils::abort_on_panic;
8+
9+
pub use reactor::{Reactor, Watcher};
10+
pub use runtime::Runtime;
11+
12+
mod reactor;
13+
mod runtime;
14+
15+
/// The global runtime.
16+
pub static RUNTIME: Lazy<Runtime> = Lazy::new(|| {
17+
thread::Builder::new()
18+
.name("async-std/runtime".to_string())
19+
.spawn(|| abort_on_panic(|| RUNTIME.run()))
20+
.expect("cannot start a runtime thread");
21+
22+
Runtime::new()
23+
});

0 commit comments

Comments
 (0)