about summary refs log tree commit diff
path: root/src/libstd/sync
AgeCommit message (Collapse)AuthorLines
2015-04-24Change name of unit test sub-module to "tests".Johannes Oertel-6/+6
Changes the style guidelines regarding unit tests to recommend using a sub-module named "tests" instead of "test" for unit tests as "test" might clash with imports of libtest.
2015-04-23Auto merge of #24633 - rapha:master, r=alexcrichtonbors-0/+57
2015-04-24Implement IntoIterator for ReceiverRaphael Speyer-0/+57
2015-04-23Indicate trait names in doc-comment are code-likeCorey Farwell-1/+1
2015-04-21std: Remove deprecated/unstable num functionalityAlex Crichton-8/+0
This commit removes all the old casting/generic traits from `std::num` that are no longer in use by the standard library. This additionally removes the old `strconv` module which has not seen much use in quite a long time. All generic functionality has been supplanted with traits in the `num` crate and the `strconv` module is supplanted with the [rust-strconv crate][rust-strconv]. [rust-strconv]: https://github.com/lifthrasiir/rust-strconv This is a breaking change due to the removal of these deprecated crates, and the alternative crates are listed above. [breaking-change]
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-27/+27
2015-04-09Indicate keyword in doc comment is code-likeCorey Farwell-2/+2
2015-04-08Auto merge of #24029 - nagisa:print-locking, r=alexcrichtonbors-202/+14
write_fmt calls write for each formatted field. The default implementation of write_fmt is used, which will call write on not-yet-locked stdout (and write locking after), therefore making print! in multithreaded environment still interleave contents of two separate prints. I’m not sure whether we want to do this change, though, because it has the same deadlock hazard which we tried to avoid by not locking inside write_fmt itself (see [this comment](https://github.com/rust-lang/rust/blob/80def6c2447d23a624e611417f24cf0ab2a5a676/src/libstd/io/stdio.rs#L267)). Spotted on [reddit]. cc @alexcrichton [reddit]: http://www.reddit.com/r/rust/comments/31comh/println_with_multiple_threads/
2015-04-08Implement reentrant mutexes and make stdio use themSimonas Kazlauskas-202/+14
write_fmt calls write for each formatted field. The default implementation of write_fmt is used, which will call write on not-yet-locked stdout (and write locking after), therefore making print! in multithreaded environment still interleave contents of two separate prints. This patch implements reentrant mutexes, changes stdio handles to use these mutexes and overrides write_fmt to lock the stdio handle for the whole duration of the call.
2015-04-07Remove another invalid exampleŁukasz Niemier-26/+0
2015-04-07Remove incorrect example from docsŁukasz Niemier-26/+0
2015-04-01Test fixes and rebase conflicts, round 2Alex Crichton-22/+22
2015-04-01rollup merge of #23176: huonw/rm-boundsAlex Crichton-34/+36
2015-04-01rollup merge of #23949: aturon/stab-timeoutAlex Crichton-19/+31
This commit renames and stabilizes: * `Condvar::wait_timeout_ms` (renamed from `wait_timeout`) * `thread::park_timeout_ms` (renamed from `park_timeout`) * `thread::sleep_ms` (renamed from `sleep`) In each case, the timeout is taken as a `u32` number of milliseconds, rather than a `Duration`. These functions are likely to be deprecated once a stable form of `Duration` is available, but there is little cost to having these named variants around, and it's crucial functionality for 1.0. [breaking-change] r? @alexcrichton cc @sfackler @carllerche
2015-04-01Stabilize basic timeout functionalityAaron Turon-19/+31
This commit renames and stabilizes: * `Condvar::wait_timeout_ms` (renamed from `wait_timeout`) * `thread::park_timeout_ms` (renamed from `park_timeout`) * `thread::sleep_ms` (renamed from `sleep`) In each case, the timeout is taken as a `u32` number of milliseconds, rather than a `Duration`. These functions are likely to be deprecated once a stable form of `Duration` is available, but there is little cost to having these named variants around, and it's crucial functionality for 1.0. [breaking-change]
2015-04-01Remove `Thunk` struct and `Invoke` trait; change `Thunk` to be an aliasNiko Matsakis-2/+3
for `Box<FnBox()>`. I found the alias was still handy because it is shorter than the fully written type. This is a [breaking-change]: convert code using `Invoke` to use `FnBox`, which is usually pretty straight-forward. Code using thunk mostly works if you change `Thunk::new => Box::new` and `foo.invoke(arg)` to `foo(arg)`.
2015-03-31rollup merge of #23873: alexcrichton/remove-deprecatedAlex Crichton-226/+0
Conflicts: src/libcollectionstest/fmt.rs src/libcollectionstest/lib.rs src/libcollectionstest/str.rs src/libcore/error.rs src/libstd/fs.rs src/libstd/io/cursor.rs src/libstd/os.rs src/libstd/process.rs src/libtest/lib.rs src/test/run-pass-fulldeps/compiler-calls.rs
2015-03-31rollup merge of #23879: seanmonstar/del-from-errorAlex Crichton-3/+3
Conflicts: src/libcore/error.rs
2015-03-31std: Clean out #[deprecated] APIsAlex Crichton-226/+0
This commit cleans out a large amount of deprecated APIs from the standard library and some of the facade crates as well, updating all users in the compiler and in tests as it goes along.
2015-03-31Indicate select! is code-likeCorey Farwell-1/+1
2015-03-30convert: remove FromError, use From<E> insteadSean McArthur-3/+3
This removes the FromError trait, since it can now be expressed using the new convert::Into trait. All implementations of FromError<E> where changed to From<E>, and `try!` was changed to use From::from instead. Because this removes FromError, it is a breaking change, but fixing it simply requires changing the words `FromError` to `From`, and `from_error` to `from`. [breaking-change]
2015-03-28Rollup merge of #23803 - richo:unused-braces, r=ManishearthManish Goregaokar-1/+1
Pretty much what it says on the tin.
2015-03-28cleanup: Remove unused braces in use statementsRicho Healey-1/+1
2015-03-26Mass rename uint/int to usize/isizeAlex Crichton-8/+8
Now that support has been removed, all lingering use cases are renamed.
2015-03-24Reject specialized Drop impls.Felix S. Klock II-1/+1
See Issue 8142 for discussion. This makes it illegal for a Drop impl to be more specialized than the original item. So for example, all of the following are now rejected (when they would have been blindly accepted before): ```rust struct S<A> { ... }; impl Drop for S<i8> { ... } // error: specialized to concrete type struct T<'a> { ... }; impl Drop for T<'static> { ... } // error: specialized to concrete region struct U<A> { ... }; impl<A:Clone> Drop for U<A> { ... } // error: added extra type requirement struct V<'a,'b>; impl<'a,'b:a> Drop for V<'a,'b> { ... } // error: added extra region requirement ``` Due to examples like the above, this is a [breaking-change]. (The fix is to either remove the specialization from the `Drop` impl, or to transcribe the requirements into the struct/enum definition; examples of both are shown in the PR's fixed to `libstd`.) ---- This is likely to be the last thing blocking the removal of the `#[unsafe_destructor]` attribute. Includes two new error codes for the new dropck check. Update run-pass tests to accommodate new dropck pass. Update tests and docs to reflect new destructor restriction. ---- Implementation notes: We identify Drop impl specialization by not being as parametric as the struct/enum definition via unification. More specifically: 1. Attempt unification of a skolemized instance of the struct/enum with an instance of the Drop impl's type expression where all of the impl's generics (i.e. the free variables of the type expression) have been replaced with unification variables. 2. If unification fails, then reject Drop impl as specialized. 3. If unification succeeds, check if any of the skolemized variables "leaked" into the constraint set for the inference context; if so, then reject Drop impl as specialized. 4. Otherwise, unification succeeded without leaking skolemized variables: accept the Drop impl. We identify whether a Drop impl is injecting new predicates by simply looking whether the predicate, after an appropriate substitution, appears on the struct/enum definition.
2015-03-24Added `T:Send` bound to `Queue<T>` to avoid specialized `Drop` impl.Felix S. Klock II-1/+1
2015-03-24Added `T:Send` bound to `Packet<T>` to avoid specialized `Drop` impl.Felix S. Klock II-2/+2
2015-03-24added `T:Send` bound to `Mutex<T>` to avoid specialized Drop impl.Felix S. Klock II-1/+1
2015-03-24Added `T:Send` bound to `Queue<T>` to avoid specialized Drop impl.Felix S. Klock II-2/+2
2015-03-24Added `T:Send` bound to `sync::mpsc::Receiver` and `sync::mpsc::Sender`.Felix S. Klock II-16/+16
This was necessary to avoid specialized `Drop` impls for the two structs.
2015-03-23rollup merge of #23598: brson/gateAlex Crichton-0/+11
Conflicts: src/compiletest/compiletest.rs src/libcollections/lib.rs src/librustc_back/lib.rs src/libserialize/lib.rs src/libstd/lib.rs src/libtest/lib.rs src/test/run-make/rustdoc-default-impl/foo.rs src/test/run-pass/env-home-dir.rs
2015-03-23rollup merge of #23541: aturon/stab-errorAlex Crichton-6/+6
This small commit stabilizes the `Error` trait as-is, except that `Send` and `Debug` are added as constraints. The `Send` constraint is because most uses of `Error` will be for trait objects, and by default we would like these objects to be transferrable between threads. The `Debug` constraint is to ensure that e.g. `Box<Error>` is `Debug`, and because types that implement `Display` should certainly implement `Debug` in any case. In the near future we expect to add `Any`-like downcasting features to `Error`, but this is waiting on some additional mechanisms (`Reflect`). It will be added before 1.0 via default methods. [breaking-change] r? @alexcrichton Closes #21790
2015-03-23Add #![feature] attributes to doctestsBrian Anderson-0/+11
2015-03-23Stabilize the Error traitAaron Turon-6/+6
This small commit stabilizes the `Error` trait as-is, except that `Send` and `Debug` are added as constraints. The `Send` constraint is because most uses of `Error` will be for trait objects, and by default we would like these objects to be transferrable between threads. The `Debug` constraint is to ensure that e.g. `Box<Error>` is `Debug`, and because types that implement `Display` should certainly implement `Debug` in any case. In the near future we expect to add `Any`-like downcasting features to `Error`, but this is waiting on some additional mechanisms (`Reflect`). It will be added before 1.0 via default methods. [breaking-change]
2015-03-21Fix documentation for std::sync::mutex: into_guard -> into_innerBarosl Lee-2/+2
2015-03-20don't use Result::ok just to be able to use unwrap/unwrap_orOliver Schneider-1/+1
2015-03-13Remove explicit syntax highlight from docs.Joseph Crail-6/+6
2015-03-11Example -> ExamplesSteve Klabnik-11/+11
This brings comments in line with https://github.com/rust-lang/rfcs/blob/master/text/0505-api-comment-conventions.md#using-markdown
2015-03-10Rollup merge of #23125 - danburkert:master, r=brsonManish Goregaokar-0/+63
2015-03-09Rename #[should_fail] to #[should_panic]Steven Fackler-3/+3
2015-03-08Remove unneeded `Send` bounds from `std::sync::mpsc`.Huon Wilson-29/+29
The requirements `T: Send` only matter if the channel crosses thread boundaries i.e. the `Sender` or `Reciever` are sent across thread boundaries, and which is adequately controlled by the impls of `Send` for them. If `T` doesn't satisfy the bounds, then the types cannot cross thread boundaries and so everything is still safe (the pair of types collectively behave like a `Rc<RefCell<VecDeque>>`, or something of that nature).
2015-03-08Remove unneeded `Send`/`Sync` bounds from `Mutex`/`RwLock`.Huon Wilson-5/+7
The requirements `T: Send` and `T: Send + Sync` for `Mutex` and `RwLock` respectively only matter if those types are shared/sent across thread boundaries, and that is adequately controlled by the impls of `Send`/`Sync` for them. If `T` doesn't satisfy the bounds, then the types cannot cross thread boundaries and so everything is still safe (the two types just act like an expensive `RefCell`).
2015-03-06Implement std::error::Error for std::sync::mpsc error typesDan Burkert-0/+63
2015-03-03Add `: Box<_>` or `::Box<_>` type annotations to various places.Felix S. Klock II-6/+6
This is the kind of change that one is expected to need to make to accommodate overloaded-`box`. ---- Note that this is not *all* of the changes necessary to accommodate Issue 22181. It is merely the subset of those cases where there was already a let-binding in place that made it easy to add the necesasry type ascription. (For unnamed intermediate `Box` values, one must go down a different route; `Box::new` is the option that maximizes portability, but has potential inefficiency depending on whether the call is inlined.) ---- There is one place worth note, `run-pass/coerce-match.rs`, where I used an ugly form of `Box<_>` type ascription where I would have preferred to use `Box::new` to accommodate overloaded-`box`. I deliberately did not use `Box::new` here, because that is already done in coerce-match-calls.rs. ---- Precursor for overloaded-`box` and placement-`in`; see Issue 22181.
2015-03-02Use `const`s instead of `static`s where appropriateFlorian Zeitz-9/+9
This changes the type of some public constants/statics in libunicode. Notably some `&'static &'static [(char, char)]` have changed to `&'static [(char, char)]`. The regexp crate seems to be the sole user of these, yet this is technically a [breaking-change]
2015-02-27Rollup merge of #22803 - huonw:field-stability, r=alexcrichtonManish Goregaokar-1/+1
We were recording stability attributes applied to fields in the compiler, and even annotating it in the libs, but the compiler didn't actually do the checks to give errors/warnings in user crates. Details in the commit messages.
2015-02-27Auto merge of #22573 - nwin:impl-debug-rwlock-weak, r=Manishearthbors-0/+28
Implements `Debug` for `RwLock` and `arc::Weak` in the same way it is implemented for `rc::Weak` (basically copy & paste). The lack of this implementation prevents the automatic implementation of `Debug` for structs containing members of these types.
2015-02-27Add some missing stability attributes on struct fields.Huon Wilson-1/+1
2015-02-26Implement `Debug` for `RwLock`, `arc::Weak` and `Mutex`nwin-0/+28
2015-02-25allow(deprecated) for TaskPool (fixup #22783)Manish Goregaokar-0/+3