about summary refs log tree commit diff
path: root/src/libstd/rt/mod.rs
AgeCommit message (Collapse)AuthorLines
2013-12-24green: Rip the bandaid off, introduce libgreenAlex Crichton-57/+7
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: 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-0/+3
2013-12-16Fallout of rewriting std::commAlex Crichton-14/+7
2013-12-10libextra: Another round of de-`Cell`-ing.Patrick Walton-16/+17
34 uses of `Cell` remain.
2013-12-04Rename std::rt::deque::*::init() to *::new()Kevin Ballard-1/+1
2013-12-03Register new snapshotsAlex Crichton-5/+0
2013-11-29Implement a lock-free work-stealing dequeAlex Crichton-11/+12
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-28Register new snapshotsAlex Crichton-1/+1
2013-11-27Use the native tls implementation on androidAlex Crichton-5/+3
Turns out android doesn't support LLVM's thread_local attribute and accompanying implementation. Closes #10686
2013-11-26Clean up statically initialized data on shutdownAlex Crichton-3/+14
Whenever the runtime is shut down, add a few hooks to clean up some of the statically initialized data of the runtime. Note that this is an unsafe operation because there's no guarantee on behalf of the runtime that there's no other code running which is using the runtime. This helps turn down the noise a bit in the valgrind output related to statically initialized mutexes. It doesn't turn the noise down to 0 because there are still statically initialized mutexes in dynamic_lib and os::with_env_lock, but I believe that it would be easy enough to add exceptions for those cases and I don't think that it's the runtime's job to go and clean up that data.
2013-11-26auto merge of #10312 : thestinger/rust/thread_local, r=alexcritchtonbors-0/+4
This provides a building block for fast thread-local storage. It does not change the safety semantics of `static mut`. Closes #10310
2013-11-26port the runtime to `#[thread_local]`Daniel Micay-0/+4
2013-11-26librustc: Make `||` lambdas not infer to `proc`sPatrick Walton-3/+3
2013-11-24Remove linked failure from the runtimeAlex Crichton-1/+1
The reasons for doing this are: * The model on which linked failure is based is inherently complex * The implementation is also very complex, and there are few remaining who fully understand the implementation * There are existing race conditions in the core context switching function of the scheduler, and possibly others. * It's unclear whether this model of linked failure maps well to a 1:1 threading model Linked failure is often a desired aspect of tasks, but we would like to take a much more conservative approach in re-implementing linked failure if at all. Closes #8674 Closes #8318 Closes #8863
2013-11-18libstd: Change all `~fn()`s to `proc`s in the standard library.Patrick Walton-6/+6
This makes `Cell`s no longer necessary in most cases.
2013-11-11Move std::rt::io to std::ioAlex Crichton-2/+4
2013-11-11Remove #[fixed_stack_segment] and #[rust_stack]Alex Crichton-2/+0
These two attributes are no longer useful now that Rust has decided to leave segmented stacks behind. It is assumed that the rust task's stack is always large enough to make an FFI call (due to the stack being very large). There's always the case of stack overflow, however, to consider. This does not change the behavior of stack overflow in Rust. This is still normally triggered by the __morestack function and aborts the whole process. C stack overflow will continue to corrupt the stack, however (as it did before this commit as well). The future improvement of a guard page at the end of every rust stack is still unimplemented and is intended to be the mechanism through which we attempt to detect C stack overflow. Closes #8822 Closes #10155
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-10-29Register new snapshotsAlex Crichton-11/+0
2013-10-29Move rust's uv implementation to its own crateAlex Crichton-3/+29
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-28Make some more rt components publicAlex Crichton-12/+10
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-28Allow fail messages to be caught, and introduce the Any traitMarvin Löbel-3/+4
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-25add multi-producer multi-consumer bounded queue to use for sleeper listJason Toffaletti-0/+3
2013-10-25lock-free queue for scheduler message queueJason Toffaletti-0/+3
2013-10-24Implement a basic event loop built on LittleLockAlex Crichton-0/+3
It's not guaranteed that there will always be an event loop to run, and this implementation will serve as an incredibly basic one which does not provide any I/O, but allows the scheduler to still run. cc #9128
2013-10-24Migrate Rtio objects to true trait objectsAlex Crichton-2/+2
This moves as many as I could over to ~Trait instead of ~Typedef. The only remaining one is the IoFactoryObject which should be coming soon...
2013-10-14std::rt: Fix the set up of the main thread so that it doesn't try to steal workBrian Anderson-2/+8
This is causing really awful scheduler behavior where the main thread scheduler is continually waking up, stealing work, discovering it can't actually run the work, and sending it off to another scheduler.
2013-10-11De-pub some private runtime componentsAlex Crichton-6/+17
This change was waiting for privacy to get sorted out, which should be true now that #8215 has landed. Closes #4427
2013-10-09auto merge of #9742 : alexcrichton/rust/issue-9739, r=brsonbors-2/+8
This changes an `assert_once_ever!` assertion to just a plain old assertion around an atomic boolean to ensure that one particular runtime doesn't attempt to exit twice. Closes #9739
2013-10-09Don't abort if the runtime is run twice.Alex Crichton-2/+8
This changes an `assert_once_ever!` assertion to just a plain old assertion around an atomic boolean to ensure that one particular runtime doesn't attempt to exit twice. Closes #9739
2013-10-07Fix existing privacy/visibility violationsAlex Crichton-2/+15
This commit fixes all of the fallout of the previous commit which is an attempt to refine privacy. There were a few unfortunate leaks which now must be plugged, and the most horrible one is the current `shouldnt_be_public` module now inside `std::rt`. I think that this either needs a slight reorganization of the runtime, or otherwise it needs to just wait for the external users of these modules to get replaced with their `rt` implementations. Other fixes involve making things pub which should be pub, and otherwise updating error messages that now reference privacy instead of referencing an "unresolved name" (yay!).
2013-09-23Register new snapshotsAlex Crichton-30/+0
2013-09-23auto merge of #9301 : luqmana/rust/ncm, r=brsonbors-1/+30
Get rid of the crate_map arg! r? @brson
2013-09-20Implement a web backend for rustdoc_ngAlex Crichton-1/+2
This large commit implements and `html` output option for rustdoc_ng. The executable has been altered to be invoked as "rustdoc_ng html <crate>" and it will dump everything into the local "doc" directory. JSON can still be generated by changing 'html' to 'json'. This also fixes a number of bugs in rustdoc_ng relating to comment stripping, along with some other various issues that I found along the way. The `make doc` command has been altered to generate the new documentation into the `doc/ng/$(CRATE)` directories.
2013-09-18librustc/libstd: No longer pass crate_map to start.Luqman Aden-1/+30
2013-09-18Register new snapshotsAlex Crichton-12/+0
2013-09-13Convert rust_crate_map.cpp to RustFlorian Hahn-0/+3
Conflicts: src/libstd/rt/logging.rs
2013-09-09rename `std::iterator` to `std::iter`Daniel Micay-1/+1
The trait will keep the `Iterator` naming, but a more concise module name makes using the free functions less verbose. The module will define iterables in addition to iterators, as it deals with iteration in general.
2013-08-29rt: use sugary functions rather than manual range loops.Huon Wilson-11/+7
2013-08-27Consolidate local_data implementations, and cleanupAlex Crichton-4/+0
This moves all local_data stuff into the `local_data` module and only that module alone. It also removes a fair amount of "super-unsafe" code in favor of just vanilla code generated by the compiler at the same time. Closes #8113
2013-08-27librustc: Ensure that type parameters are in the right positions in paths.Patrick Walton-3/+5
This removes the stacking of type parameters that occurs when invoking trait methods, and fixes all places in the standard library that were relying on it. It is somewhat awkward in places; I think we'll probably want something like the `Foo::<for T>::new()` syntax.
2013-08-27Rename UnsafeAtomicRcBox to UnsafeArc. Fixes #7674.Huon Wilson-2/+2
2013-08-24std::rt: Remove metrics for perfBrian Anderson-2/+0
These aren't used for anything at the moment and cause some TLS hits on some perf-critical code paths. Will need to put better thought into it in the future.
2013-08-23rt: Remove old precise GC codeBrian Anderson-3/+0
2013-08-20Add assert_once_ever macro. Close #7748. (fixme cf #8472)Ben Blum-0/+1
2013-08-19Add externfn macro and correctly label fixed_stack_segmentsNiko Matsakis-3/+13
2013-08-16doc: convert remaining uses of core:: to std::.Huon Wilson-12/+12
2013-08-13auto merge of #8475 : kmcallister/rust/stack_segment, r=brson,brsonbors-1/+1
Servo needs to tell SpiderMonkey about the stack bounds. r? @brson
2013-08-13Make rt::stack publicKeegan McAllister-1/+1
Fixes #8478.