about summary refs log tree commit diff
path: root/src/libstd/io
AgeCommit message (Collapse)AuthorLines
2014-01-28Rename OwnedCopyableVector to OwnedCloneableVectorVirgile Andreani-2/+2
2014-01-28Rename CopyableVector to CloneableVectorVirgile Andreani-1/+1
2014-01-28auto merge of #11845 : xales/rust/libnative, r=alexcrichtonbors-0/+40
Fixes std::net test error when re-running too quickly. Suggested by @cmr
2014-01-27Set SO_REUSEADDR by default in libnative.xales-0/+40
Fixes std::net test error when re-running too quickly.
2014-01-27Demote self to an (almost) regular argument and remove the env param.Eduard Burtescu-1/+1
Fixes #10667 and closes #10259.
2014-01-26Removed all instances of XXX in preparation for relaxing of FIXME ruleSalem Talha-16/+16
2014-01-25auto merge of #11808 : huonw/rust/std-visible-types, r=brsonbors-1/+1
These are either returned from public functions, and really should appear in the documentation, but don't since they're private, or are implementation details that are currently public.
2014-01-26std,extra: Make some types public and other private.Huon Wilson-1/+1
These are either returned from public functions, and really should appear in the documentation, but don't since they're private, or are implementation details that are currently public.
2014-01-25Uppercase numeric constantsChris Wong-13/+13
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-24auto merge of #11732 : luqmana/rust/native-getaddrinfo, r=alexcrichtonbors-5/+11
The last bit I needed to be able to use libnative :P
2014-01-24libstd: Use iotest! for for get_host_addresses.Luqman Aden-5/+11
2014-01-22Implement native timersAlex Crichton-29/+146
Native timers are a much hairier thing to deal with than green timers due to the interface that we would like to expose (both a blocking sleep() and a channel-based interface). I ended up implementing timers in three different ways for the various platforms that we supports. In all three of the implementations, there is a worker thread which does send()s on channels for timers. This worker thread is initialized once and then communicated to in a platform-specific manner, but there's always a shared channel available for sending messages to the worker thread. * Windows - I decided to use windows kernel timer objects via CreateWaitableTimer and SetWaitableTimer in order to provide sleeping capabilities. The worker thread blocks via WaitForMultipleObjects where one of the objects is an event that is used to wake up the helper thread (which then drains the incoming message channel for requests). * Linux/(Android?) - These have the ideal interface for implementing timers, timerfd_create. Each timer corresponds to a timerfd, and the helper thread uses epoll to wait for all active timers and then send() for the next one that wakes up. The tricky part in this implementation is updating a timerfd, but see the implementation for the fun details * OSX/FreeBSD - These obviously don't have the windows APIs, and sadly don't have the timerfd api available to them, so I have thrown together a solution which uses select() plus a timeout in order to ad-hoc-ly implement a timer solution for threads. The implementation is backed by a sorted array of timers which need to fire. As I said, this is an ad-hoc solution which is certainly not accurate timing-wise. I have done this implementation due to the lack of other primitives to provide an implementation, and I've done it the best that I could, but I'm sure that there's room for improvement. I'm pretty happy with how these implementations turned out. In theory we could drop the timerfd implementation and have linux use the select() + timeout implementation, but it's so inaccurate that I would much rather continue to use timerfd rather than my ad-hoc select() implementation. The only change that I would make to the API in general is to have a generic sleep() method on an IoFactory which doesn't require allocating a Timer object. For everything but windows it's super-cheap to request a blocking sleep for a set amount of time, and it's probably worth it to provide a sleep() which doesn't do something like allocate a file descriptor on linux.
2014-01-21[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old ↵Simon Sapin-3/+3
from_utf8_owned() behavior
2014-01-21[std::str] Rename from_utf8_opt() to from_utf8(), drop the old from_utf8() ↵Simon Sapin-9/+9
behavior
2014-01-21[std::vec] Rename .shift_opt() to .shift(), drop the old .shift() behaviorSimon Sapin-2/+2
2014-01-21[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behaviorSimon Sapin-2/+5
2014-01-21Remove unnecessary parentheses.Huon Wilson-1/+1
2014-01-18Rename iterators for consistencyPalmer Cox-21/+21
Rename existing iterators to get rid of the Iterator suffix and to give them names that better describe the things being iterated over.
2014-01-17auto merge of #11598 : alexcrichton/rust/io-export, r=brsonbors-91/+134
* Reexport io::mem and io::buffered structs directly under io, make mem/buffered private modules * Remove with_mem_writer * Remove DEFAULT_CAPACITY and use DEFAULT_BUF_SIZE (in io::buffered) cc #11119
2014-01-17Tweak the interface of std::ioAlex Crichton-91/+134
* Reexport io::mem and io::buffered structs directly under io, make mem/buffered private modules * Remove with_mem_writer * Remove DEFAULT_CAPACITY and use DEFAULT_BUF_SIZE (in io::buffered)
2014-01-15Issue #3511 - Rationalize temporary lifetimes.Niko Matsakis-9/+11
Major changes: - Define temporary scopes in a syntax-based way that basically defaults to the innermost statement or conditional block, except for in a `let` initializer, where we default to the innermost block. Rules are documented in the code, but not in the manual (yet). See new test run-pass/cleanup-value-scopes.rs for examples. - Refactors Datum to better define cleanup roles. - Refactor cleanup scopes to not be tied to basic blocks, permitting us to have a very large number of scopes (one per AST node). - Introduce nascent documentation in trans/doc.rs covering datums and cleanup in a more comprehensive way.
2014-01-15auto merge of #11112 : alexcrichton/rust/issue-11087, r=brsonbors-4/+4
This should allow callers to know whether the channel was empty or disconnected without having to block. Closes #11087
2014-01-15Allow more "error" values in try_recv()Alex Crichton-4/+4
This should allow callers to know whether the channel was empty or disconnected without having to block. Closes #11087
2014-01-14Mark LineIterator as public so its docs get generated.a_m0d-1/+1
2014-01-14auto merge of #11485 : eddyb/rust/sweep-old-rust, r=nikomatsakisbors-3/+3
2014-01-13std: Ignore bind error tests on android. #11530Brian Anderson-2/+4
2014-01-12Removed remnants of `@mut` and `~mut` from comments and the type system.Eduard Burtescu-3/+3
2014-01-10auto merge of #11416 : bjz/rust/remove-print-fns, r=alexcrichtonbors-4/+4
The `print!` and `println!` macros are now the preferred method of printing, and so there is no reason to export the `stdio` functions in the prelude. The functions have also been replaced by their macro counterparts in the tutorial and other documentation so that newcomers don't get confused about what they should be using.
2014-01-11Remove re-exports of std::io::stdio::{print, println} in the prelude.Brendan Zabarauskas-4/+4
The `print!` and `println!` macros are now the preferred method of printing, and so there is no reason to export the `stdio` functions in the prelude. The functions have also been replaced by their macro counterparts in the tutorial and other documentation so that newcomers don't get confused about what they should be using.
2014-01-10std::io: Optimize u64_from_be_bytes()Carl-Anton Ingmarsson-11/+19
Instead of reading a byte at a time in a loop we copy the relevant bytes into a temporary vector of size eight. We can then read the value from the temporary vector using a single u64 read. LLVM seems to be able to optimize this almost scarily good.
2014-01-10std::io: Add tests and benchmarks for u64_from_be_bytes()Carl-Anton Ingmarsson-0/+82
2014-01-09Add eof to MemReader and BufReaderSteven Fackler-2/+12
It's easy to figure out and useful as a sanity check sometimes.
2014-01-09Remove eof() from io::ReaderAlex Crichton-142/+18
2014-01-08Remove the io::Decorator traitAlex Crichton-192/+118
This is just an unnecessary trait that no one's ever going to parameterize over and it's more useful to just define the methods directly on the types themselves. The implementors of this type almost always don't want inner_mut_ref() but they're forced to define it as well.
2014-01-08Robustly read remaining bytes in a characterAlex Crichton-4/+16
Closes #11372
2014-01-07stdtest: Fix all leaked trait importsAlex Crichton-11/+12
2014-01-07std: Fill in all missing importsAlex Crichton-1/+7
Fallout from the previous commits
2014-01-07auto merge of #11353 : alexcrichton/rust/improve-logging, r=brsonbors-27/+105
This will allow capturing of common things like logging messages, stdout prints (using stdio println), and failure messages (printed to stderr). Any new prints added to libstd should be funneled through these task handles to allow capture as well. Additionally, this commit redirects logging back through a `Logger` trait so the log level can be usefully consumed by an arbitrary logger. This commit also introduces methods to set the task-local stdout handles: * std::io::stdio::set_stdout * std::io::stdio::set_stderr * std::io::logging::set_logger These methods all return the previous logger just in case it needs to be used for inspection. I plan on using this infrastructure for extra::test soon, but we don't quite have the primitives that I'd like to use for it, so it doesn't migrate extra::test at this time. Closes #6369
2014-01-07auto merge of #11329 : fhahn/rust/unused-cast-lint2, r=alexcrichtonbors-9/+9
Updates as mentioned in #11135
2014-01-06Don't read forever on a file descriptorAlex Crichton-0/+22
Similarly to the recent commit to do this for networking, there's no reason that a read on a file descriptor should continue reading until the entire buffer is full. This makes sense when dealing with literal files, but when dealing with things like stdin this doesn't make sense.
2014-01-06Support arbitrary stdout/stderr/logger handlesAlex Crichton-27/+105
This will allow capturing of common things like logging messages, stdout prints (using stdio println), and failure messages (printed to stderr). Any new prints added to libstd should be funneled through these task handles to allow capture as well. Additionally, this commit redirects logging back through a `Logger` trait so the log level can be usefully consumed by an arbitrary logger. This commit also introduces methods to set the task-local stdout handles: * std::io::stdio::set_stdout * std::io::stdio::set_stderr * std::io::logging::set_logger These methods all return the previous logger just in case it needs to be used for inspection. I plan on using this infrastructure for extra::test soon, but we don't quite have the primitives that I'd like to use for it, so it doesn't migrate extra::test at this time. Closes #6369
2014-01-06Remove some unnecessary type castsFlorian Hahn-9/+9
Conflicts: src/librustc/middle/lint.rs
2014-01-06auto merge of #11334 : alexcrichton/rust/fix-native-tcp, r=pcwaltonbors-0/+21
libnative erroneously would attempt to fill the entire buffer in a call to `read` before returning, when rather it should return immediately because there's not guaranteed to be any data that will ever be received again. Close #11328
2014-01-06Don't wait for a full buffer when reading TCPAlex Crichton-0/+21
libnative erroneously would attempt to fill the entire buffer in a call to `read` before returning, when rather it should return immediately because there's not guaranteed to be any data that will ever be received again. Close #11328
2014-01-05Fix some warningsCorey Richardson-2/+1
2014-01-04auto merge of #11310 : Dretch/rust/write_char, r=alexcrichtonbors-0/+18
2014-01-04Don't allow newtype structs to be dereferenced. #6246Brian Anderson-11/+46
2014-01-04auto merge of #11271 : adridu59/rust/patch-io, r=huonwbors-21/+45
2014-01-04Restore Writer.write_char, see #10861.Gareth Smith-0/+18
2014-01-04std: io: add some code examplesAdrien Tétar-21/+45
Closes #11232.