summary refs log tree commit diff
path: root/src/libstd/rt
AgeCommit message (Collapse)AuthorLines
2013-11-04Move io::file to io::fs and fns out of FileAlex Crichton-301/+350
This renames the `file` module to `fs` because that more accurately describes its current purpose (manipulating the filesystem, not just files). Additionally, this adds an UnstableFileStat structure as a nested structure of FileStat to signify that the fields should not be depended on. The structure is currently flagged with #[unstable], but it's unlikely that it has much meaning. Closes #10241
2013-11-03Fill out the remaining functionality in io::fileAlex Crichton-575/+919
This adds bindings to the remaining functions provided by libuv, all of which are useful operations on files which need to get exposed somehow. Some highlights: * Dropped `FileReader` and `FileWriter` and `FileStream` for one `File` type * Moved all file-related methods to be static methods under `File` * All directory related methods are still top-level functions * Created `io::FilePermission` types (backed by u32) that are what you'd expect * Created `io::FileType` and refactored `FileStat` to use FileType and FilePermission * Removed the expanding matrix of `FileMode` operations. The mode of reading a file will not have the O_CREAT flag, but a write mode will always have the O_CREAT flag. Closes #10130 Closes #10131 Closes #10121
2013-11-03Remove all blocking std::os blocking functionsAlex Crichton-415/+900
This commit moves all thread-blocking I/O functions from the std::os module. Their replacements can be found in either std::rt::io::file or in a hidden "old_os" module inside of native::file. I didn't want to outright delete these functions because they have a lot of special casing learned over time for each OS/platform, and I imagine that these will someday get integrated into a blocking implementation of IoFactory. For now, they're moved to a private module to prevent bitrot and still have tests to ensure that they work. I've also expanded the extensions to a few more methods defined on Path, most of which were previously defined in std::os but now have non-thread-blocking implementations as part of using the current IoFactory. The api of io::file is in flux, but I plan on changing it in the next commit as well. Closes #10057
2013-11-03Modify IoFactory's fs_mkdir, and add fs_renameAlex Crichton-1/+2
The invocation for making a directory should be able to specify a mode to make the directory with (instead of defaulting to one particular mode). Additionally, libuv and various OSes implement efficient versions of renaming files, so this operation is exposed as an IoFactory call.
2013-11-01Remove unnecessary unwind messagesAlex Crichton-55/+26
Now that the type_id intrinsic is working across crates, all of these unnecessary messages can be removed to have the failure type for a task truly be ~Any and only ~Any
2013-11-01auto merge of #10204 : alexcrichton/rust/better-names, r=brsonbors-0/+3
Tests now have the same name as the test that they're running (to allow for easier diagnosing of failure sources), and the main task is now specially named `<main>` instead of `<unnamed>`. Closes #10195 Closes #10073
2013-11-01auto merge of #10119 : Kimundi/rust/option_and_generic, r=alexcrichtonbors-1/+1
This takes the last reforms on the `Option` type and applies them to `Result` too. For that, I reordered and grouped the functions in both modules, and also did some refactorings: - Added `as_ref` and `as_mut` adapters to `Result`. - Renamed `Result::map_move` to `Result::map` (same for `_err` variant), deleted other map functions. - Made the `.expect()` methods be generic over anything you can fail with. - Updated some doc comments to the line doc comment style - Cleaned up and extended standard trait implementations on `Option` and `Result` - Removed legacy implementations in the `option` and `result` module
2013-11-01Give test and main tasks better namesAlex Crichton-0/+3
Tests now have the same name as the test that they're running (to allow for easier diagnosing of failure sources), and the main task is now specially named <main> instead of <unnamed>. Closes #10195 Closes #10073
2013-11-01auto merge of #10218 : alexcrichton/rust/stdio-flush-safe, r=cmrbors-14/+27
The previous method was unsound because you could very easily create two mutable pointers which alias the same location (not sound behavior). This hides the function which does so and then exports an explicit flush() function (with documentation about how it works).
2013-11-01Reordered the methods in std::Option and std::ResultMarvin Löbel-1/+1
Cleaned up the source in a few places Renamed `map_move` to `map`, removed other `map` methods Added `as_ref` and `as_mut` adapters to `Result` Added `fmt::Default` impl
2013-10-31Provide a sound method of flushing stdoutAlex Crichton-14/+27
The previous method was unsound because you could very easily create two mutable pointers which alias the same location (not sound behavior). This hides the function which does so and then exports an explicit flush() function (with documentation about how it works).
2013-10-31libstd: Remove mocks.Patrick Walton-181/+131
2013-10-31auto merge of #10180 : alexcrichton/rust/flush-default, r=brsonbors-31/+6
Closes #9126
2013-10-30auto merge of #10120 : Kimundi/rust/remove_sys, r=alexcrichtonbors-24/+57
- `begin_unwind` and `fail!` is now generic over any `T: Any + Send`. - Every value you fail with gets boxed as an `~Any`. - Because of implementation issues, `&'static str` and `~str` are still handled specially behind the scenes. - Changed the big macro source string in libsyntax to a raw string literal, and enabled doc comments there.
2013-10-30Make Writer::flush a no-op default methodAlex Crichton-31/+6
Closes #9126
2013-10-30Prepared `std::sys` for removal, and made `begin_unwind` simplerMarvin Löbel-24/+57
- `begin_unwind` is now generic over any `T: Any + Send`. - Every value you fail with gets boxed as an `~Any`. - Because of implementation details, `&'static str` and `~str` are still handled specially behind the scenes. - Changed the big macro source string in libsyntax to a raw string literal, and enabled doc comments there.
2013-10-30auto merge of #10168 : reedlepee123/rust/priv_fields, r=brsonbors-21/+21
....rs #8180
2013-10-30auto merge of #9613 : jld/rust/enum-discrim-size.r0, r=alexcrichtonbors-0/+1
Allows an enum with a discriminant to use any of the primitive integer types to store it. By default the smallest usable type is chosen, but this can be overridden with an attribute: `#[repr(int)]` etc., or `#[repr(C)]` to match the target's C ABI for the equivalent C enum. Also adds a lint pass for using non-FFI safe enums in extern declarations, checks that specified discriminants can be stored in the specified type if any, and fixes assorted code that was assuming int.
2013-10-30changed all the impl<T> to impl<T: Send> in rt::comm.rs and libstd::comm.rs ↵reedlepee-21/+21
#8180
2013-10-29Register new snapshotsAlex Crichton-6760/+0
2013-10-29auto merge of #10140 : brson/rust/comm, r=alexcrichtonbors-7/+1
Just putting this public trait into the correct module.
2013-10-29auto merge of #10132 : pcwalton/rust/proc, r=pcwaltonbors-7/+9
the feature gate for `once fn` if used with the `~` sigil. r? @brson
2013-10-29librustc: Implement the `proc` type as sugar for `~once fn` and `proc`Patrick Walton-7/+9
notation for closures, and disable the feature gate for `once fn` if used with the `~` sigil.
2013-10-29auto merge of #10058 : alexcrichton/rust/uv-crate, r=brsonbors-41/+87
This is one of the final steps needed to complete #9128. It still needs a little bit of polish before closing that issue, but it's in a pretty much "done" state now. The idea here is that the entire event loop implementation using libuv is now housed in `librustuv` as a completely separate library. This library is then injected (via `extern mod rustv`) into executable builds (similarly to how libstd is injected, tunable via `#[no_uv]`) to bring in the "rust blessed event loop implementation." Codegen-wise, there is a new `event_loop_factory` language item which is tagged on a function with 0 arguments returning `~EventLoop`. This function's symbol is then inserted into the crate map for an executable crate, and if there is no definition of the `event_loop_factory` language item then the value is null. What this means is that embedding rust as a library in another language just got a little harder. Libraries don't have crate maps, which means that there's no way to find the event loop implementation to spin up the runtime. That being said, it's always possible to build the runtime manually. This request also makes more runtime components public which should probably be public anyway. This new public-ness should allow custom scheduler setups everywhere regardless of whether you follow the `rt::start `path.
2013-10-29Add repr attributes in various places that need them.Jed Davis-0/+1
2013-10-29Move rust's uv implementation to its own crateAlex Crichton-18/+72
There are a few reasons that this is a desirable move to take: 1. Proof of concept that a third party event loop is possible 2. Clear separation of responsibility between rt::io and the uv-backend 3. Enforce in the future that the event loop is "pluggable" and replacable Here's a quick summary of the points of this pull request which make this possible: * Two new lang items were introduced: event_loop, and event_loop_factory. The idea of a "factory" is to define a function which can be called with no arguments and will return the new event loop as a trait object. This factory is emitted to the crate map when building an executable. The factory doesn't have to exist, and when it doesn't then an empty slot is in the crate map and a basic event loop with no I/O support is provided to the runtime. * When building an executable, then the rustuv crate will be linked by default (providing a default implementation of the event loop) via a similar method to injecting a dependency on libstd. This is currently the only location where the rustuv crate is ever linked. * There is a new #[no_uv] attribute (implied by #[no_std]) which denies implicitly linking to rustuv by default Closes #5019
2013-10-29auto merge of #10141 : kmcallister/rust/current_stack_segment, r=alexcrichtonbors-1/+4
This was done in 2145de8c and reverted in 0ada7c7f, but Servo needs it. Closes #10065. r? @brson
2013-10-29auto merge of #10135 : alexcrichton/rust/snapshots, r=thestingerbors-110/+83
Plus some migration from `let mut this = self` to `mut self` (yay!)
2013-10-28auto merge of #10127 : thestinger/rust/cold, r=pcwaltonbors-0/+1
This allows a function to marked as infrequently called, resulting in any branch calling it to be considered colder.
2013-10-28rt::task: Make current_stack_segment public againKeegan McAllister-1/+4
This was done in 2145de8c and reverted in 0ada7c7f, but Servo needs it. Closes #10065.
2013-10-28std: Move the SendDeferred trait to std::commBrian Anderson-7/+1
2013-10-28auto merge of #10133 : alexcrichton/rust/another-error, r=thestingerbors-1/+2
This cropped up on the bsd bot, and if it's an error that gets thrown then it's fine to just whitelist another type of error in the test.
2013-10-28Register new snapshotsAlex Crichton-110/+83
2013-10-28Make some more rt components publicAlex Crichton-23/+15
Primarily this makes the Scheduler and all of its related interfaces public. The reason for doing this is that currently any extern event loops had no access to the scheduler at all. This allows third-party event loops to manipulate the scheduler, along with allowing the uv event loop to live inside of its own crate.
2013-10-28add support for the `cold` function attributeDaniel Micay-0/+1
This allows a function to marked as infrequently called, resulting in any branch calling it to be considered colder.
2013-10-28Handle another possible error in a unix pipe testAlex Crichton-1/+2
This cropped up on the bsd bot, and if it's an error that gets thrown then it's fine to just whitelist another type of error in the test.
2013-10-28Remove the extension traits for Readers/WritersAlex Crichton-606/+487
These methods are all excellent candidates for default methods, so there's no need to require extra imports of various traits.
2013-10-28auto merge of #10094 : alexcrichton/rust/issue-8704, r=pcwaltonbors-65/+248
This drops more of the old C++ runtime to rather be written in rust. A few features were lost along the way, but hopefully not too many. The main loss is that there are no longer backtraces associated with allocations (rust doesn't have a way of acquiring those just yet). Other than that though, I believe that the rest of the debugging utilities made their way over into rust. Closes #8704
2013-10-28auto merge of #10093 : alexcrichton/rust/issue-8811, r=pcwaltonbors-6/+15
Closes #8811
2013-10-28auto merge of #10083 : alexcrichton/rust/timer-port, r=pcwaltonbors-6/+170
In addition to being able to sleep the current task, timers should be able to create ports which get notified after a period of time. Closes #10014
2013-10-28Allow fail messages to be caught, and introduce the Any traitMarvin Löbel-100/+192
Some code cleanup, sorting of import blocks Removed std::unstable::UnsafeArc's use of Either Added run-fail tests for the new FailWithCause impls Changed future_result and try to return Result<(), ~Any>. - Internally, there is an enum of possible fail messages passend around. - In case of linked failure or a string message, the ~Any gets lazyly allocated in future_results recv method. - For that, future result now returns a wrapper around a Port. - Moved and renamed task::TaskResult into rt::task::UnwindResult and made it an internal enum. - Introduced a replacement typedef `type TaskResult = Result<(), ~Any>`.
2013-10-27auto merge of #10080 : brson/rust/sched_queue, r=brsonbors-105/+444
Rebase and update of #9710
2013-10-27Ignore a test which never completes on windowsAlex Crichton-0/+1
I'm not entirely sure why this is happening, but the server task is never seeing the second send of the client task, and this test will very reliably fail to complete on windows.
2013-10-26Fix a typo in a rt::io::signal testAlex Crichton-1/+1
It was pretty much a miracle that these tests were ever passing. They would never have passed in the single threaded case because only one sigint in the tests is ever generated, but when run in parallel two sigints will be generated.
2013-10-26Implement another error code found on windows.Alex Crichton-6/+15
Closes #8811
2013-10-26Rewrite boxed_region/memory_region in RustAlex Crichton-65/+248
This drops more of the old C++ runtime to rather be written in rust. A few features were lost along the way, but hopefully not too many. The main loss is that there are no longer backtraces associated with allocations (rust doesn't have a way of acquiring those just yet). Other than that though, I believe that the rest of the debugging utilities made their way over into rust. Closes #8704
2013-10-26auto merge of #10070 : alexcrichton/rust/fewer-missiles, r=brsonbors-36/+49
This optimizes the `home_for_io` code path by requiring fewer scheduler operations in some situtations. When moving to your home scheduler, this no longer forces a context switch if you're already on the home scheduler. Instead, the homing code now simply pins you to your current scheduler (making it so you can't be stolen away). If you're not on your home scheduler, then we context switch away, sending you to your home scheduler. When the I/O operation is done, then we also no longer forcibly trigger a context switch. Instead, the action is cased on whether the task is homed or not. If a task does not have a home, then the task is re-flagged as not having a home and no context switch is performed. If a task is homed to the current scheduler, then we don't do anything, and if the task is homed to a foreign scheduler, then it's sent along its merry way. I verified that there are about a third as many `write` syscalls done in print operations now. Libuv uses write to implement async handles, and the homing before and after each I/O operation was triggering a write on these async handles. Additionally, using the terrible benchmark of printing 10k times in a loop, this drives the runtime from 0.6s down to 0.3s (yay!).
2013-10-25Enhance timers to create portsAlex Crichton-6/+170
In addition to being able to sleep the current task, timers should be able to create ports which get notified after a period of time. Closes #10014
2013-10-25Encapsulate the lock-free mpsc queue in the MessageQueue typeBrian Anderson-57/+15
2013-10-25Add links to original mpmc and mpsc implementationsBrian Anderson-0/+3