summary refs log tree commit diff
path: root/src/libstd/rt
AgeCommit message (Collapse)AuthorLines
2013-12-24green: Rip the bandaid off, introduce libgreenAlex Crichton-3442/+327
This extracts everything related to green scheduling from libstd and introduces a new libgreen crate. This mostly involves deleting most of std::rt and moving it to libgreen. Along with the movement of code, this commit rearchitects many functions in the scheduler in order to adapt to the fact that Local::take now *only* works on a Task, not a scheduler. This mostly just involved threading the current green task through in a few locations, but there were one or two spots where things got hairy. There are a few repercussions of this commit: * tube/rc have been removed (the runtime implementation of rc) * There is no longer a "single threaded" spawning mode for tasks. This is now encompassed by 1:1 scheduling + communication. Convenience methods have been introduced that are specific to libgreen to assist in the spawning of pools of schedulers.
2013-12-24std: Handle prints with literally no contextAlex Crichton-3/+14
Printing is an incredibly useful debugging utility, and it's not much help if your debugging prints just trigger an obscure abort when you need them most. In order to handle this case, forcibly fall back to a libc::write implementation of printing whenever a local task is not available. Note that this is *not* a 1:1 fallback. All 1:1 rust tasks will still have a local Task that it can go through (and stdio will be created through the local IO factory), this is only a fallback for "no context" rust code (such as that setting up the context).
2013-12-24std: Expose that LocalIo may not always be availableAlex Crichton-23/+37
It is not the case that all programs will always be able to acquire an instance of the LocalIo borrow, so this commit exposes this limitation by returning Option<LocalIo> from LocalIo::borrow(). At the same time, a helper method LocalIo::maybe_raise() has been added in order to encapsulate the functionality of raising on io_error if there is on local I/O available.
2013-12-24std: Introduce std::syncAlex Crichton-1378/+0
For now, this moves the following modules to std::sync * UnsafeArc (also removed unwrap method) * mpsc_queue * spsc_queue * atomics * mpmc_bounded_queue * deque We may want to remove some of the queues, but for now this moves things out of std::rt into std::sync
2013-12-24std: Delete rt::testAlex Crichton-440/+0
This module contains many M:N specific concepts. This will no longer be available with libgreen, and most functions aren't really that necessary today anyway. New testing primitives will be introduced as they become available for 1:1 and M:N. A new io::test module is introduced with the new ip4/ip6 address helpers to continue usage in io tests.
2013-12-24std: Introduce an unstable::stack moduleAlex Crichton-2/+2
This module will be used to manage the OS-specific TLS registers used to specify the bounds of the current rust stack (useful in 1:1 and M:N)
2013-12-24std: Introduce a Runtime traitAlex Crichton-269/+25
This trait is used to abstract the differences between 1:1 and M:N scheduling and is the sole dispatch point for the differences between these two scheduling modes. This, and the following series of commits, is not intended to compile. Only after the entire transition is complete are programs expected to compile.
2013-12-24Stop using C++ exceptions for stack unwinding.Vadim Chugunov-66/+261
2013-12-20std: silence warnings when compiling test.Huon Wilson-6/+14
2013-12-18auto merge of #11029 : huonw/rust/rm-vec-as-buf, r=cmrbors-7/+5
For `str.as_mut_buf`, un-closure-ification is achieved by outright removal (see commit message). The others are replaced by `.as_ptr`, `.as_mut_ptr` and `.len`
2013-12-19std::vec: remove .as_muf_buf, replaced by .as_mut_ptr & .len.Huon Wilson-7/+5
2013-12-17Don't allow impls to force public typesAlex Crichton-1/+1
This code in resolve accidentally forced all types with an impl to become public. This fixes it by default inheriting the privacy of what was previously there and then becoming `true` if nothing else exits. Closes #10545
2013-12-16Test fallout from std::comm rewriteAlex Crichton-5/+9
2013-12-16Fallout of rewriting std::commAlex Crichton-1446/+220
2013-12-16Rewrite std::commAlex Crichton-122/+423
* Streams are now ~3x faster than before (fewer allocations and more optimized) * Based on a single-producer single-consumer lock-free queue that doesn't always have to allocate on every send. * Blocking via mutexes/cond vars outside the runtime * Streams work in/out of the runtime seamlessly * Select now works in/out of the runtime seamlessly * Streams will now fail!() on send() if the other end has hung up * try_send() will not fail * PortOne/ChanOne removed * SharedPort removed * MegaPipe removed * Generic select removed (only one kind of port now) * API redesign * try_recv == never block * recv_opt == block, don't fail * iter() == Iterator<T> for Port<T> * removed peek * Type::new * Removed rt::comm
2013-12-15librustc: Remove identifiers named `box`, since it's about to become a keyword.Patrick Walton-32/+37
2013-12-15auto merge of #10984 : huonw/rust/clean-raw, r=cmrbors-3/+3
See commits for details.
2013-12-15std::vec: convert to(_mut)_ptr to as_... methods on &[] and &mut [].Huon Wilson-2/+2
2013-12-15Move std::{str,vec}::raw::set_len to an unsafe method on Owned{Vector,Str}.Huon Wilson-1/+1
2013-12-15std::rt: s/pausible/pausable/.Huon Wilson-18/+18
2013-12-15std: fix spelling in docs.Huon Wilson-1/+1
2013-12-11Make 'self lifetime illegal.Erik Price-9/+9
Also remove all instances of 'self within the codebase. This fixes #10889.
2013-12-10auto merge of #10791 : pcwalton/rust/decelling, r=pcwaltonbors-307/+311
34 uses of `Cell` remain. r? @alexcrichton
2013-12-10libstd: Remove `Cell` from the library.Patrick Walton-13/+18
2013-12-10Make crate hash stable and externally computable.Jack Moffitt-2/+0
This replaces the link meta attributes with a pkgid attribute and uses a hash of this as the crate hash. This makes the crate hash computable by things other than the Rust compiler. It also switches the hash function ot SHA1 since that is much more likely to be available in shell, Python, etc than SipHash. Fixes #10188, #8523.
2013-12-10libstd: Remove two uses of `Cell`.Patrick Walton-6/+4
2013-12-10libstd: Change `atomically` to use RAII.Patrick Walton-11/+7
2013-12-10librustuv: Change `with_local_io` to use RAII.Patrick Walton-25/+53
2013-12-10libstd: Remove some cells involved inPatrick Walton-10/+6
`deschedule_running_task_and_then`.
2013-12-10librustuv: RAII-ify `Local::borrow`, and remove some 12 Cells.Patrick Walton-146/+168
2013-12-10libextra: Another round of de-`Cell`-ing.Patrick Walton-110/+69
34 uses of `Cell` remain.
2013-12-08Remove dead codesKiet Tran-22/+6
2013-12-06auto merge of #10364 : Kimundi/rust/result_compose, r=alexcrichtonbors-0/+1
This implements parts of the changes to `Result` and `Option` I proposed and discussed in this thread: https://mail.mozilla.org/pipermail/rust-dev/2013-November/006254.html This PR includes: - Adding `ok()` and `err()` option adapters for both `Result` variants. - Removing `get_ref`, `expect` and iterator constructors for `Result`, as they are reachable with the variant adapters. - Removing `Result`s `ToStr` bound on the error type because of composability issues. (See https://mail.mozilla.org/pipermail/rust-dev/2013-November/006283.html) - Some warning cleanups
2013-12-06Link rustllvm statically, and distribute a static snapshotAlex Crichton-0/+1
In order to keep up to date with changes to the libraries that `llvm-config` spits out, the dependencies to the LLVM are a dynamically generated rust file. This file is now automatically updated whenever LLVM is updated to get kept up-to-date. At the same time, this cleans out some old cruft which isn't necessary in the makefiles in terms of dependencies. Closes #10745 Closes #10744
2013-12-06Made Results API more composableMarvin Löbel-0/+1
2013-12-05auto merge of #10817 : alexcrichton/rust/sched-fix, r=brsonbors-4/+49
Right now, as pointed out in #8132, it is very easy to introduce a subtle race in the runtime. I believe that this is the cause of the current flakiness on the bots. I have taken the last idea mentioned in that issue which is to use a lock around descheduling and context switching in order to solve this race. Closes #8132
2013-12-05Solve some nasty deschedulinging races with a lockAlex Crichton-4/+49
Right now, as pointed out in #8132, it is very easy to introduce a subtle race in the runtime. I believe that this is the cause of the current flakiness on the bots. I have taken the last idea mentioned in that issue which is to use a lock around descheduling and context switching in order to solve this race. Closes #8132
2013-12-04Rename std::rt::deque::*::init() to *::new()Kevin Ballard-20/+20
2013-12-04Revert "libstd: Change `Path::new` to `Path::init`."Kevin Ballard-1/+1
This reverts commit c54427ddfbbab41a39d14f2b1dc4f080cbc2d41b. Leave the #[ignores] in that were added to rustpkg tests. Conflicts: src/librustc/driver/driver.rs src/librustc/metadata/creader.rs
2013-12-03Move std::util::ignore to std::prelude::dropSteven Fackler-2/+1
It's a more fitting name for the most common use case of this function.
2013-12-03auto merge of #10747 : alexcrichton/rust/snapshots, r=cmrbors-5/+0
This registers new snapshots after the landing of #10528, and then goes on to tweak the build process to build a monolithic `rustc` binary for use in future snapshots. This mainly involved dropping the dynamic dependency on `librustllvm`, so that's now built as a static library (with a dynamically generated rust file listing LLVM dependencies). This currently doesn't actually make the snapshot any smaller (24MB => 23MB), but I noticed that the executable has 11MB of metadata so once progress is made on #10740 we should have a much smaller snapshot. There's not really a super-compelling reason to distribute just a binary because we have all the infrastructure for dealing with a directory structure, but to me it seems "more correct" that a snapshot compiler is just a `rustc` binary.
2013-12-03Register new snapshotsAlex Crichton-5/+0
2013-11-30auto merge of #10733 : alexcrichton/rust/ignore-on-windows, r=pcwaltonbors-0/+1
I've seen this fail on windows twice now, and it's not clear to me why it's failing. For now, ignore it on that platform while investigation enuses.
2013-11-29Ignore a deque test on windowsAlex Crichton-0/+1
I've seen this fail on windows twice now, and it's not clear to me why it's failing. For now, ignore it on that platform while investigation enuses.
2013-11-29auto merge of #10719 : Kimundi/rust/switch_to_multi_item_macros, r=alexcrichtonbors-2/+1
- Removed module reexport workaround for the integer module macros - Removed legacy reexports of `cmp::{min, max}` in the integer module macros - Combined a few macros in `vec` into one - Documented a few issues
2013-11-29Implement a lock-free work-stealing dequeAlex Crichton-132/+714
This adds an implementation of the Chase-Lev work-stealing deque to libstd under std::rt::deque. I've been unable to break the implementation of the deque itself, and it's not super highly optimized just yet (everything uses a SeqCst memory ordering). The major snag in implementing the chase-lev deque is that the buffers used to store data internally cannot get deallocated back to the OS. In the meantime, a shared buffer pool (synchronized by a normal mutex) is used to deallocate/allocate buffers from. This is done in hope of not overcommitting too much memory. It is in theory possible to eventually free the buffers, but one must be very careful in doing so. I was unable to get some good numbers from src/test/bench tests (I don't think many of them are slamming the work queue that much), but I was able to get some good numbers from one of my own tests. In a recent rewrite of select::select(), I found that my implementation was incredibly slow due to contention on the shared work queue. Upon switching to the parallel deque, I saw the contention drop to 0 and the runtime go from 1.6s to 0.9s with the most amount of time spent in libuv awakening the schedulers (plus allocations). Closes #4877
2013-11-29Removed useless cmp::{min, max} reexports from the integer modulesMarvin Löbel-2/+1
2013-11-29libstd: Change `Path::new` to `Path::init`.Patrick Walton-1/+1
2013-11-28Register new snapshotsAlex Crichton-10/+9
2013-11-27Use the native tls implementation on androidAlex Crichton-248/+227
Turns out android doesn't support LLVM's thread_local attribute and accompanying implementation. Closes #10686