about summary refs log tree commit diff
path: root/src/libstd/task
AgeCommit message (Collapse)AuthorLines
2013-12-24green: Rip the bandaid off, introduce libgreenAlex Crichton-1032/+0
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-20std: silence warnings when compiling test.Huon Wilson-8/+0
2013-12-16Test fallout from std::comm rewriteAlex Crichton-1/+1
2013-12-16Fallout of rewriting std::commAlex Crichton-63/+30
2013-12-10librustuv: RAII-ify `Local::borrow`, and remove some 12 Cells.Patrick Walton-10/+10
2013-12-10libextra: Another round of de-`Cell`-ing.Patrick Walton-22/+9
34 uses of `Cell` remain.
2013-11-29Implement a lock-free work-stealing dequeAlex Crichton-3/+2
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-27Improve the rt::thread moduleAlex Crichton-1/+1
* Added doc comments explaining what all public functionality does. * Added the ability to spawn a detached thread * Added the ability for the procs to return a value in 'join'
2013-11-26librustc: Make `||` lambdas not infer to `proc`sPatrick Walton-6/+6
2013-11-26test: Remove non-procedure uses of `do` from compiletest, libstd tests,Patrick Walton-16/+16
compile-fail tests, run-fail tests, and run-pass tests.
2013-11-26libstd: Remove all non-`proc` uses of `do` from libstdPatrick Walton-5/+3
2013-11-24Remove linked failure from the runtimeAlex Crichton-1162/+18
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-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-17/+19
2013-11-18auto merge of #10561 : pcwalton/rust/procify, r=alexcrichtonbors-22/+24
r? @alexcrichton
2013-11-18Remove the C++ lock_and_signal typeAlex Crichton-22/+12
A the same time this purges all runtime support needed for statically initialized mutexes, moving all users over to the new Mutex type instead.
2013-11-18libstd: Change all `~fn()`s to `proc`s in the standard library.Patrick Walton-22/+24
This makes `Cell`s no longer necessary in most cases.
2013-11-11Remove #[fixed_stack_segment] and #[rust_stack]Alex Crichton-6/+8
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-10Remove a debug! statement before I/O is readyAlex Crichton-1/+0
The logging macros all use libuv-based I/O, and there was one stray debug statement in task::spawn which was executing before the I/O context was ready. Remove it and add a test to make sure that we can continue to debug this sort of code. Closes #10405
2013-11-01Remove unnecessary unwind messagesAlex Crichton-18/+11
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-10-30Prepared `std::sys` for removal, and made `begin_unwind` simplerMarvin Löbel-20/+35
- `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-29Move rust's uv implementation to its own crateAlex Crichton-9/+5
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-5/+9
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-28auto merge of #10095 : huonw/rust/master, r=cmrbors-2/+2
Currently each line is a separate bullet point in a list: http://static.rust-lang.org/doc/master/std/task/fn.spawn_sched.html
2013-10-28Allow fail messages to be caught, and introduce the Any traitMarvin Löbel-66/+159
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-27Make the documentation for std::task::spawn_sched render correctly.Huon Wilson-2/+2
Currently each line is a separate bullet point in a list: http://static.rust-lang.org/doc/master/std/task/fn.spawn_sched.html
2013-10-24Implement a basic event loop built on LittleLockAlex Crichton-42/+42
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-23Removed Unnecessary comments and white spaces #4386reedlepee-12/+8
2013-10-23Making fields in std and extra : private #4386reedlepee-15/+19
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-33/+33
Who doesn't like a massive renaming?
2013-10-18Made `std::task::TaskBuilder::future_result()` easier to useMarvin Löbel-31/+26
2013-10-11De-pub some private runtime componentsAlex Crichton-7/+7
This change was waiting for privacy to get sorted out, which should be true now that #8215 has landed. Closes #4427
2013-10-09option: rewrite the API to use compositionDaniel Micay-8/+8
2013-10-07Fix merge fallout of privacy changesAlex Crichton-1/+1
2013-10-07Fix existing privacy/visibility violationsAlex Crichton-9/+4
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-10-05Implemented `IntoSendStr` on `SendStr` to allow naming aMarvin Löbel-0/+15
task with a `SendStr` directly
2013-10-05Make a task name use a `SendStr`, allowing for eitherMarvin Löbel-4/+20
static or owned strings
2013-10-01auto merge of #9576 : FlaPer87/rust/issue/9125, r=alexcrichtonbors-19/+29
Fixes #9125
2013-10-01Update std::task::mod docstringFlavio Percoco-19/+29
2013-09-30std: Remove usage of fmt!Alex Crichton-29/+29
2013-09-25std::rt: Implement task yielding. Fix a starvation problemBrian Anderson-4/+1
2013-09-25rustdoc: Change all code-blocks with a scriptAlex Crichton-5/+5
find src -name '*.rs' | xargs sed -i '' 's/~~~.*{\.rust}/```rust/g' find src -name '*.rs' | xargs sed -i '' 's/ ~~~$/ ```/g' find src -name '*.rs' | xargs sed -i '' 's/^~~~$/ ```/g'
2013-09-16switch Drop to `&mut self`Daniel Micay-33/+28
2013-08-27Consolidate local_data implementations, and cleanupAlex Crichton-323/+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-12/+12
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-27Trailing spaceFlaper Fesp-1/+1
2013-08-27Rebased and replaced yield with descheduleFlaper Fesp-1/+1
2013-08-27Decrement unkillable counter before failingFlaper Fesp-2/+2
2013-08-27Don't make the runtime exit on illegal callsFlaper Fesp-15/+33
2013-08-27Testing rekillable fails when called from outside an unkillable blockFlaper Fesp-1/+17