diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-11 14:16:46 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-12 20:39:03 -0700 |
| commit | d54bd9f29af67748b7ddf80a5cf285145949ddc2 (patch) | |
| tree | a42b5b92bcc03e847bd6ff112154680884cf524c /src/libstd/thread.rs | |
| parent | 79dd393a4f144fa5e6f81c720c782de3175810d7 (diff) | |
| download | rust-d54bd9f29af67748b7ddf80a5cf285145949ddc2.tar.gz rust-d54bd9f29af67748b7ddf80a5cf285145949ddc2.zip | |
std: Stabilize the `io` module
The new `std::io` module has had some time to bake now, and this commit
stabilizes its functionality. There are still portions of the module which
remain unstable, and below contains a summart of the actions taken.
This commit also deprecates the entire contents of the `old_io` module in a
blanket fashion. All APIs should now have a reasonable replacement in the
new I/O modules.
Stable APIs:
* `std::io` (the name)
* `std::io::prelude` (the name)
* `Read`
* `Read::read`
* `Read::{read_to_end, read_to_string}` after being modified to return a `usize`
for the number of bytes read.
* `Write`
* `Write::write`
* `Write::{write_all, write_fmt}`
* `BufRead`
* `BufRead::{fill_buf, consume}`
* `BufRead::{read_line, read_until}` after being modified to return a `usize`
for the number of bytes read.
* `BufReader`
* `BufReader::{new, with_capacity}`
* `BufReader::{get_ref, get_mut, into_inner}`
* `{Read,BufRead} for BufReader`
* `BufWriter`
* `BufWriter::{new, with_capacity}`
* `BufWriter::{get_ref, get_mut, into_inner}`
* `Write for BufWriter`
* `IntoInnerError`
* `IntoInnerError::{error, into_inner}`
* `{Error,Display} for IntoInnerError`
* `LineWriter`
* `LineWriter::{new, with_capacity}` - `with_capacity` was added
* `LineWriter::{get_ref, get_mut, into_inner}` - `get_mut` was added)
* `Write for LineWriter`
* `BufStream`
* `BufStream::{new, with_capacities}`
* `BufStream::{get_ref, get_mut, into_inner}`
* `{BufRead,Read,Write} for BufStream`
* `stdin`
* `Stdin`
* `Stdin::lock`
* `Stdin::read_line` - added method
* `StdinLock`
* `Read for Stdin`
* `{Read,BufRead} for StdinLock`
* `stdout`
* `Stdout`
* `Stdout::lock`
* `StdoutLock`
* `Write for Stdout`
* `Write for StdoutLock`
* `stderr`
* `Stderr`
* `Stderr::lock`
* `StderrLock`
* `Write for Stderr`
* `Write for StderrLock`
* `io::Result`
* `io::Error`
* `io::Error::last_os_error`
* `{Display, Error} for Error`
Unstable APIs:
(reasons can be found in the commit itself)
* `Write::flush`
* `Seek`
* `ErrorKind`
* `Error::new`
* `Error::from_os_error`
* `Error::kind`
Deprecated APIs
* `Error::description` - available via the `Error` trait
* `Error::detail` - available via the `Display` implementation
* `thread::Builder::{stdout, stderr}`
Changes in functionality:
* `old_io::stdio::set_stderr` is now a noop as the infrastructure for printing
backtraces has migrated to `std::io`.
* The `ReadExt`, `WriteExt`, and `BufReadExt` extension traits were all removed
by folding functionality into the corresponding trait.
[breaking-change]
Diffstat (limited to 'src/libstd/thread.rs')
| -rw-r--r-- | src/libstd/thread.rs | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/libstd/thread.rs b/src/libstd/thread.rs index 5c5f9f75fd9..dcf7a37b7a6 100644 --- a/src/libstd/thread.rs +++ b/src/libstd/thread.rs @@ -148,7 +148,6 @@ use cell::UnsafeCell; use fmt; use io; use marker::PhantomData; -use old_io::stdio; use rt::{self, unwind}; use sync::{Mutex, Condvar, Arc}; use thunk::Thunk; @@ -165,10 +164,6 @@ pub struct Builder { name: Option<String>, // The size of the stack for the spawned thread stack_size: Option<usize>, - // Thread-local stdout - stdout: Option<Box<Writer + Send + 'static>>, - // Thread-local stderr - stderr: Option<Box<Writer + Send + 'static>>, } impl Builder { @@ -179,8 +174,6 @@ impl Builder { Builder { name: None, stack_size: None, - stdout: None, - stderr: None, } } @@ -202,16 +195,22 @@ impl Builder { /// Redirect thread-local stdout. #[unstable(feature = "std_misc", reason = "Will likely go away after proc removal")] - pub fn stdout(mut self, stdout: Box<Writer + Send + 'static>) -> Builder { - self.stdout = Some(stdout); + #[deprecated(since = "1.0.0", + reason = "the old I/O module is deprecated and this function \ + will be removed with no replacement")] + #[allow(deprecated)] + pub fn stdout(self, _stdout: Box<Writer + Send + 'static>) -> Builder { self } /// Redirect thread-local stderr. #[unstable(feature = "std_misc", reason = "Will likely go away after proc removal")] - pub fn stderr(mut self, stderr: Box<Writer + Send + 'static>) -> Builder { - self.stderr = Some(stderr); + #[deprecated(since = "1.0.0", + reason = "the old I/O module is deprecated and this function \ + will be removed with no replacement")] + #[allow(deprecated)] + pub fn stderr(self, _stderr: Box<Writer + Send + 'static>) -> Builder { self } @@ -259,7 +258,7 @@ impl Builder { } fn spawn_inner<T: Send>(self, f: Thunk<(), T>) -> io::Result<JoinInner<T>> { - let Builder { name, stack_size, stdout, stderr } = self; + let Builder { name, stack_size } = self; let stack_size = stack_size.unwrap_or(rt::min_stack()); @@ -290,16 +289,6 @@ impl Builder { } let mut output = None; - let f: Thunk<(), T> = if stdout.is_some() || stderr.is_some() { - Thunk::new(move || { - let _ = stdout.map(stdio::set_stdout); - let _ = stderr.map(stdio::set_stderr); - f.invoke(()) - }) - } else { - f - }; - let try_result = { let ptr = &mut output; |
