Skip to content

New scheduler #733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Apr 7, 2020
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ default = [
"async-task",
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-queue",
"futures-timer",
"kv-log-macro",
"log",
Expand Down Expand Up @@ -58,6 +59,7 @@ async-task = { version = "1.3.1", optional = true }
broadcaster = { version = "1.0.0", optional = true }
crossbeam-channel = { version = "0.4.2", optional = true }
crossbeam-deque = { version = "0.7.3", optional = true }
crossbeam-queue = { version = "0.2.0", optional = true }
crossbeam-utils = { version = "0.7.2", optional = true }
futures-core = { version = "0.3.4", optional = true, default-features = false }
futures-io = { version = "0.3.4", optional = true }
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ cfg_default! {
pub mod fs;
pub mod path;
pub mod net;
pub(crate) mod rt;
}

cfg_unstable! {
Expand Down
1 change: 0 additions & 1 deletion src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,5 @@ pub use tcp::{Incoming, TcpListener, TcpStream};
pub use udp::UdpSocket;

mod addr;
pub(crate) mod driver;
mod tcp;
mod udp;
2 changes: 1 addition & 1 deletion src/net/tcp/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;

use crate::future;
use crate::io;
use crate::net::driver::Watcher;
use crate::rt::Watcher;
use crate::net::{TcpStream, ToSocketAddrs};
use crate::stream::Stream;
use crate::task::{Context, Poll};
Expand Down
2 changes: 1 addition & 1 deletion src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;

use crate::future;
use crate::io::{self, Read, Write};
use crate::net::driver::Watcher;
use crate::rt::Watcher;
use crate::net::ToSocketAddrs;
use crate::task::{Context, Poll};

Expand Down
4 changes: 2 additions & 2 deletions src/net/udp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::net::SocketAddr;
use std::net::{Ipv4Addr, Ipv6Addr};

use crate::future;
use crate::net::driver::Watcher;
use crate::net::ToSocketAddrs;
use crate::rt::Watcher;
use crate::utils::Context as _;

/// A UDP socket.
Expand Down Expand Up @@ -102,7 +102,7 @@ impl UdpSocket {
/// ```no_run
/// # fn main() -> std::io::Result<()> { async_std::task::block_on(async {
/// #
/// use async_std::net::UdpSocket;
/// use async_std::net::UdpSocket;
///
/// let socket = UdpSocket::bind("127.0.0.1:0").await?;
/// let addr = socket.local_addr()?;
Expand Down
2 changes: 1 addition & 1 deletion src/os/unix/net/datagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use mio_uds;
use super::SocketAddr;
use crate::future;
use crate::io;
use crate::net::driver::Watcher;
use crate::rt::Watcher;
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use crate::path::Path;
use crate::task::spawn_blocking;
Expand Down
2 changes: 1 addition & 1 deletion src/os/unix/net/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::SocketAddr;
use super::UnixStream;
use crate::future;
use crate::io;
use crate::net::driver::Watcher;
use crate::rt::Watcher;
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use crate::path::Path;
use crate::stream::Stream;
Expand Down
2 changes: 1 addition & 1 deletion src/os/unix/net/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use mio_uds;

use super::SocketAddr;
use crate::io::{self, Read, Write};
use crate::net::driver::Watcher;
use crate::rt::Watcher;
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use crate::path::Path;
use crate::task::{spawn_blocking, Context, Poll};
Expand Down
23 changes: 23 additions & 0 deletions src/rt/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! The runtime.

use std::thread;

use once_cell::sync::Lazy;

use crate::utils::abort_on_panic;

pub use reactor::{Reactor, Watcher};
pub use runtime::Runtime;

mod reactor;
mod runtime;

/// The global runtime.
pub static RUNTIME: Lazy<Runtime> = Lazy::new(|| {
thread::Builder::new()
.name("async-std/runtime".to_string())
.spawn(|| abort_on_panic(|| RUNTIME.run()))
.expect("cannot start a runtime thread");

Runtime::new()
});
Loading