Skip to content

Commit 36d24cd

Browse files
author
Stjepan Glavina
committed
New scheduler resilient to blocking
1 parent 9311fd7 commit 36d24cd

22 files changed

+623
-456
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
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",
@@ -56,6 +57,7 @@ async-task = { version = "1.0.0", optional = true }
5657
broadcaster = { version = "0.2.6", optional = true, default-features = false, features = ["default-channels"] }
5758
crossbeam-channel = { version = "0.4.0", optional = true }
5859
crossbeam-deque = { version = "0.7.2", optional = true }
60+
crossbeam-queue = { version = "0.2.0", optional = true }
5961
crossbeam-utils = { version = "0.7.0", optional = true }
6062
futures-core = { version = "0.3.1", optional = true }
6163
futures-io = { version = "0.3.1", optional = true }

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ cfg_std! {
246246
pub mod stream;
247247
pub mod sync;
248248
pub mod task;
249+
250+
pub(crate) mod rt;
249251
}
250252

251253
cfg_default! {

src/net/mod.rs

Lines changed: 0 additions & 1 deletion
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;

src/net/tcp/listener.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 crate::future;
66
use crate::io;
7-
use crate::net::driver::Watcher;
7+
use crate::rt::Watcher;
88
use crate::net::{TcpStream, ToSocketAddrs};
99
use crate::stream::Stream;
1010
use crate::task::{Context, Poll};

src/net/tcp/stream.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 crate::future;
66
use crate::io::{self, Read, Write};
7-
use crate::net::driver::Watcher;
7+
use crate::rt::Watcher;
88
use crate::net::ToSocketAddrs;
99
use crate::task::{spawn_blocking, Context, Poll};
1010
use crate::utils::Context as _;

src/net/udp/mod.rs

Lines changed: 2 additions & 2 deletions
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()?;

src/os/unix/net/datagram.rs

Lines changed: 1 addition & 1 deletion
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;

src/os/unix/net/listener.rs

Lines changed: 1 addition & 1 deletion
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;

src/os/unix/net/stream.rs

Lines changed: 1 addition & 1 deletion
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};

src/rt/mod.rs

Lines changed: 23 additions & 0 deletions
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)