Skip to content

Commit 62ff64b

Browse files
committed
auto merge of #18557 : aturon/rust/io-removal, r=alexcrichton
This PR includes a sequence of commits that gradually dismantles the `librustrt` `rtio` system -- the main trait previously used to abstract over green and native io. It also largely dismantles `libnative`, moving much of its code into `libstd` and refactoring as it does so. TL;DR: * Before this PR: `rustc hello.rs && wc -c hello` produces 715,996 * After this PR: `rustc hello.rs && wc -c hello` produces 368,100 That is, this PR reduces the footprint of hello world by ~50%. This is a major step toward #17325 (i.e. toward implementing the [runtime removal RFC](rust-lang/rfcs#230).) What remains is to pull out the scheduling, synchronization and task infrastructure, and to remove `libgreen`. These will be done soon in a follow-up PR. Part of the work here is eliminating the `rtio` abstraction, which in many cases means bringing the implementation of io closer to the actual API presented in `std::io`. Another aspect of this PR is the creation of two new, *private* modules within `std` that implement io: * The `sys` module, which represents a platform-specific implementation of a number of low-level abstractions that are used directly within `std::io` and `std::os`. These "abstractions" are left largely the same as they were in `libnative` (except for the removal of `Arc` in file descriptors), but they are expected to evolve greatly over time. Organizationally, there are `sys/unix/` and `sys/windows/` directories which both implement the entire `sys` module hierarchy; this means that nearly all of the platform-specific code is isolated and you can get a handle on each platform in isolation. * The `sys_common` module, which is rooted at `sys/common`, and provides a few pieces of private, low-level, but cross-platform functionality. In the long term, the `sys` modules will provide hooks for exposing high-level platform-specific APIs as part of `libstd`. The first such API will be access to file descriptors from `std::io` abstractions, but a bit of design work remains before that step can be taken. The `sys_common` module includes some traits (like `AsFileDesc`) which allow communication of private details between modules in disparate locations in the hierarchy; this helps overcome the relatively simple hierarchical privacy system in Rust. To emphasize: the organization in `sys` is *very preliminary* and the main goal was to migrate away from `rtio` as quickly and simply as possible. The design will certainly evolve over time, and all of the details are currently private. Along the way, this PR also entirely removes signal handling, since it was only supported on `librustuv` which was removed a while ago. Because of the removal of APIs from `libnative` and `librustrt`, and the removal of signal handling, this is a: [breaking-change] Some of these APIs will return in public from from `std` over time. r? @alexcrichton
2 parents b80edf1 + 2c9bb3f commit 62ff64b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3928
-3581
lines changed

src/libgreen/basic.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use alloc::arc::Arc;
1919
use std::sync::atomic;
2020
use std::mem;
21-
use std::rt::rtio::{EventLoop, IoFactory, RemoteCallback};
21+
use std::rt::rtio::{EventLoop, RemoteCallback};
2222
use std::rt::rtio::{PausableIdleCallback, Callback};
2323
use std::rt::exclusive::Exclusive;
2424

@@ -150,8 +150,6 @@ impl EventLoop for BasicLoop {
150150
Box<RemoteCallback + Send>
151151
}
152152

153-
fn io<'a>(&'a mut self) -> Option<&'a mut IoFactory> { None }
154-
155153
fn has_active_io(&self) -> bool { false }
156154
}
157155

src/libgreen/simple.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use std::mem;
1616
use std::rt::Runtime;
1717
use std::rt::local::Local;
1818
use std::rt::mutex::NativeMutex;
19-
use std::rt::rtio;
2019
use std::rt::task::{Task, BlockedTask, TaskOpts};
2120

2221
struct SimpleTask {
@@ -79,9 +78,10 @@ impl Runtime for SimpleTask {
7978
_f: proc():Send) {
8079
panic!()
8180
}
82-
fn local_io<'a>(&'a mut self) -> Option<rtio::LocalIo<'a>> { None }
81+
8382
fn stack_bounds(&self) -> (uint, uint) { panic!() }
8483
fn stack_guard(&self) -> Option<uint> { panic!() }
84+
8585
fn can_block(&self) -> bool { true }
8686
fn wrap(self: Box<SimpleTask>) -> Box<Any+'static> { panic!() }
8787
}

src/libgreen/task.rs

-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use std::raw;
2424
use std::rt::Runtime;
2525
use std::rt::local::Local;
2626
use std::rt::mutex::NativeMutex;
27-
use std::rt::rtio;
2827
use std::rt::stack;
2928
use std::rt::task::{Task, BlockedTask, TaskOpts};
3029
use std::rt;
@@ -468,14 +467,6 @@ impl Runtime for GreenTask {
468467
sched.run_task(me, sibling)
469468
}
470469

471-
// Local I/O is provided by the scheduler's event loop
472-
fn local_io<'a>(&'a mut self) -> Option<rtio::LocalIo<'a>> {
473-
match self.sched.as_mut().unwrap().event_loop.io() {
474-
Some(io) => Some(rtio::LocalIo::new(io)),
475-
None => None,
476-
}
477-
}
478-
479470
fn stack_bounds(&self) -> (uint, uint) {
480471
let c = self.coroutine.as_ref()
481472
.expect("GreenTask.stack_bounds called without a coroutine");

0 commit comments

Comments
 (0)