summary refs log tree commit diff
path: root/src/libstd/sync/mutex.rs
AgeCommit message (Collapse)AuthorLines
2017-12-27Correct a few stability attributesOliver Middleton-1/+1
2017-11-18impl From<T> for Mutex<T>Eduardo Pinho-0/+11
2017-10-10Rollup merge of #44775 - MaloJaffre:debug-struct, r=sfacklerkennytm-3/+10
Refactor to use `debug_struct` in several Debug impls Also use `pad` and derive `Debug` for `Edge`. Fixes #44771.
2017-10-09Refactor to use `debug_struct` in several Debug implsMalo Jaffré-3/+10
Fixes #44771.
2017-10-04Add missing urls for MutexGuillaume Gomez-7/+17
2017-07-10Correct some stability attributesOliver Middleton-1/+1
These show up in rustdoc so need to be correct.
2017-06-22Ensure Guard types impl Display & DebugChris MacNaughton-0/+7
Fixes #24372
2017-05-20Correct some stability versionsOliver Middleton-2/+2
These were found by running tidy on stable versions of rust and finding features stabilised with the wrong version numbers.
2017-04-29need to pick a new feature nameRalf Jung-1/+1
2017-04-29MutexGuard<T> may be Sync only if T is SyncRalf Jung-5/+3
Also remove some unnecessary unsafe impl from the tests.
2017-04-09Minor fix to mutex exampleGeoffry Song-1/+1
Presumably `N` was supposed to be used in both places.
2017-04-03Fix mutex's docs inconsistencyGuillaume Gomez-7/+7
2017-03-19Rollup merge of #40611 - ScottAbbey:patch-1, r=GuillaumeGomezCorey Farwell-1/+1
Fix typo in mutex.rs docs This seems to match other uses of "be accessed" in the document.
2017-03-17Fix typo in mutex.rs docsScottAbbey-1/+1
This seems to match other uses of "be accessed" in the document.
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-3/+3
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-02-23Add missing urls in MutexGuard docsGuillaume Gomez-1/+3
2017-01-29Fix a few impl stability attributesOliver Middleton-1/+1
The versions show up in rustdoc.
2017-01-10Add missing doc examples for MutexGuillaume Gomez-1/+79
2016-12-28Replace uses of `#[unsafe_destructor_blind_to_params]` with `#[may_dangle]`Andrew Paseltiner-2/+1
CC #34761
2016-12-18Implement `fmt::Debug` for all structures in libstd.Corey Farwell-0/+9
Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-11-25Document how the `MutexGuard` structure is created.Corey Farwell-1/+8
Also, end sentence with a period.
2016-09-30Ignore various entire test modules on emscriptenBrian Anderson-9/+1
2016-09-30Ignore lots and lots of std tests on emscriptenBrian Anderson-0/+8
2016-09-11Documentation of what does for each typeathulappadan-0/+1
2016-08-24Use `#[prelude_import]` in `libstd`.Jeffrey Seyfried-4/+0
2016-07-12std: Clean out deprecated APIsAlex Crichton-173/+46
This primarily removes a lot of `sync::Static*` APIs and rejiggers the associated implementations. While doing this it was discovered that the `is_poisoned` method can actually result in a data race for the Mutex/RwLock primitives, so the inner `Cell<bool>` was changed to an `AtomicBool` to prevent the associated data race. Otherwise the usage/gurantees should be the same they were before.
2016-06-03Auto merge of #33861 - Amanieu:lock_elision_fix, r=alexcrichtonbors-1/+5
Make sure Mutex and RwLock can't be re-locked on the same thread Fixes #33770 r? @alexcrichton
2016-06-02Fix undefined behavior when re-locking a mutex from the same threadAmanieu d'Antras-1/+5
The only applies to pthread mutexes. We solve this by creating the mutex with the PTHREAD_MUTEX_NORMAL type, which guarantees that re-locking from the same thread will deadlock.
2016-05-24std: Stabilize APIs for the 1.10 releaseAlex Crichton-1/+27
This commit applies the FCP decisions made by the libs team for the 1.10 cycle, including both new stabilizations and deprecations. Specifically, the list of APIs is: Stabilized: * `os::windows::fs::OpenOptionsExt::access_mode` * `os::windows::fs::OpenOptionsExt::share_mode` * `os::windows::fs::OpenOptionsExt::custom_flags` * `os::windows::fs::OpenOptionsExt::attributes` * `os::windows::fs::OpenOptionsExt::security_qos_flags` * `os::unix::fs::OpenOptionsExt::custom_flags` * `sync::Weak::new` * `Default for sync::Weak` * `panic::set_hook` * `panic::take_hook` * `panic::PanicInfo` * `panic::PanicInfo::payload` * `panic::PanicInfo::location` * `panic::Location` * `panic::Location::file` * `panic::Location::line` * `ffi::CStr::from_bytes_with_nul` * `ffi::CStr::from_bytes_with_nul_unchecked` * `ffi::FromBytesWithNulError` * `fs::Metadata::modified` * `fs::Metadata::accessed` * `fs::Metadata::created` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange` * `sync::atomic::Atomic{Usize,Isize,Bool,Ptr}::compare_exchange_weak` * `collections::{btree,hash}_map::{Occupied,Vacant,}Entry::key` * `os::unix::net::{UnixStream, UnixListener, UnixDatagram, SocketAddr}` * `SocketAddr::is_unnamed` * `SocketAddr::as_pathname` * `UnixStream::connect` * `UnixStream::pair` * `UnixStream::try_clone` * `UnixStream::local_addr` * `UnixStream::peer_addr` * `UnixStream::set_read_timeout` * `UnixStream::set_write_timeout` * `UnixStream::read_timeout` * `UnixStream::write_Timeout` * `UnixStream::set_nonblocking` * `UnixStream::take_error` * `UnixStream::shutdown` * Read/Write/RawFd impls for `UnixStream` * `UnixListener::bind` * `UnixListener::accept` * `UnixListener::try_clone` * `UnixListener::local_addr` * `UnixListener::set_nonblocking` * `UnixListener::take_error` * `UnixListener::incoming` * RawFd impls for `UnixListener` * `UnixDatagram::bind` * `UnixDatagram::unbound` * `UnixDatagram::pair` * `UnixDatagram::connect` * `UnixDatagram::try_clone` * `UnixDatagram::local_addr` * `UnixDatagram::peer_addr` * `UnixDatagram::recv_from` * `UnixDatagram::recv` * `UnixDatagram::send_to` * `UnixDatagram::send` * `UnixDatagram::set_read_timeout` * `UnixDatagram::set_write_timeout` * `UnixDatagram::read_timeout` * `UnixDatagram::write_timeout` * `UnixDatagram::set_nonblocking` * `UnixDatagram::take_error` * `UnixDatagram::shutdown` * RawFd impls for `UnixDatagram` * `{BTree,Hash}Map::values_mut` * `<[_]>::binary_search_by_key` Deprecated: * `StaticCondvar` - this, and all other static synchronization primitives below, are usable today through the lazy-static crate on stable Rust today. Additionally, we'd like the non-static versions to be directly usable in a static context one day, so they're unlikely to be the final forms of the APIs in any case. * `CONDVAR_INIT` * `StaticMutex` * `MUTEX_INIT` * `StaticRwLock` * `RWLOCK_INIT` * `iter::Peekable::is_empty` Closes #27717 Closes #27720 cc #27784 (but encode methods still exist) Closes #30014 Closes #30425 Closes #30449 Closes #31190 Closes #31399 Closes #31767 Closes #32111 Closes #32281 Closes #32312 Closes #32551 Closes #33018
2016-04-22doc: that line was too longTshepang Lekhonkhobe-2/+2
2016-04-17Add a comment about locking a `Mutex` multiple timesTobias Bucher-0/+9
Fixes #32260.
2016-04-15Implement `Default` for more types in the standard libraryTobias Bucher-0/+7
Also add `Hash` to `std::cmp::Ordering` and most possible traits to `fmt::Error`.
2016-03-22try! -> ?Jorge Aparicio-2/+2
Automated conversion using the untry tool [1] and the following command: ``` $ find -name '*.rs' -type f | xargs untry ``` at the root of the Rust repo. [1]: https://github.com/japaric/untry
2016-02-08std: `_lock` -> `_guard` in Mutex exampleBenjamin Herr-1/+1
The comment in the next line was already talking about `_guard`, and the scope guard a couple lines further down is also called `guard`, so I assume that was just a typo.
2016-02-06Auto merge of #31428 - reem:remove-mutexguard-map, r=alexcrichtonbors-60/+1
It could return in the future if it returned a different guard type, which could not be used with Condvar, otherwise it is unsafe as another thread can invalidate an "inner" reference during a Condvar::wait. cc #27746
2016-02-05Remove MutexGuard::map, as it is not safe in combination with Condvar.Jonathan Reem-60/+1
It could return in the future if it returned a different guard type, which could not be used with Condvar, otherwise it is unsafe as another thread can invalidate an "inner" reference during a Condvar::wait. cc #27746
2016-02-05Remove an unnecessary 'static bound in the impl of Debug for Mutex.Jonathan Reem-1/+1
There is no reason to require T: 'static; the bound appears to be a historical artifact.
2016-02-03Auto merge of #30834 - reem:rwlock-read-guard-map, r=alexcrichtonbors-22/+85
This is very useful when the RwLock is synchronizing access to a data structure and you would like to return or store guards which contain references to data inside the data structure instead of the data structure itself.
2016-02-02Add issue number to guard map methods.Jonathan Reem-18/+28
2016-02-01docs: Standardize on 'Errors' header in std docsKamal Marhubi-4/+4
2016-01-30Change MutexGuard and RwLockWriteGuard to store &mut T not &UnsafeCell<T>Jonathan Reem-18/+19
This centralizes the unsafety of converting from UnsafeCell<T> to &mut T.
2016-01-29Add guard map methods for transforming guards to contain sub-borrows.Jonathan Reem-1/+53
This is very useful when the lock is synchronizing access to a data structure and you would like to return or store guards which contain references to data inside the data structure instead of the data structure itself.
2015-12-05std: Stabilize APIs for the 1.6 releaseAlex Crichton-2/+2
This commit is the standard API stabilization commit for the 1.6 release cycle. The list of issues and APIs below have all been through their cycle-long FCP and the libs team decisions are listed below Stabilized APIs * `Read::read_exact` * `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`) * libcore -- this was a bit of a nuanced stabilization, the crate itself is now marked as `#[stable]` and the methods appearing via traits for primitives like `char` and `str` are now also marked as stable. Note that the extension traits themeselves are marked as unstable as they're imported via the prelude. The `try!` macro was also moved from the standard library into libcore to have the same interface. Otherwise the functions all have copied stability from the standard library now. * The `#![no_std]` attribute * `fs::DirBuilder` * `fs::DirBuilder::new` * `fs::DirBuilder::recursive` * `fs::DirBuilder::create` * `os::unix::fs::DirBuilderExt` * `os::unix::fs::DirBuilderExt::mode` * `vec::Drain` * `vec::Vec::drain` * `string::Drain` * `string::String::drain` * `vec_deque::Drain` * `vec_deque::VecDeque::drain` * `collections::hash_map::Drain` * `collections::hash_map::HashMap::drain` * `collections::hash_set::Drain` * `collections::hash_set::HashSet::drain` * `collections::binary_heap::Drain` * `collections::binary_heap::BinaryHeap::drain` * `Vec::extend_from_slice` (renamed from `push_all`) * `Mutex::get_mut` * `Mutex::into_inner` * `RwLock::get_mut` * `RwLock::into_inner` * `Iterator::min_by_key` (renamed from `min_by`) * `Iterator::max_by_key` (renamed from `max_by`) Deprecated APIs * `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`) * `OsString::from_bytes` * `OsStr::to_cstring` * `OsStr::to_bytes` * `fs::walk_dir` and `fs::WalkDir` * `path::Components::peek` * `slice::bytes::MutableByteVector` * `slice::bytes::copy_memory` * `Vec::push_all` (renamed to `extend_from_slice`) * `Duration::span` * `IpAddr` * `SocketAddr::ip` * `Read::tee` * `io::Tee` * `Write::broadcast` * `io::Broadcast` * `Iterator::min_by` (renamed to `min_by_key`) * `Iterator::max_by` (renamed to `max_by_key`) * `net::lookup_addr` New APIs (still unstable) * `<[T]>::sort_by_key` (added to mirror `min_by_key`) Closes #27585 Closes #27704 Closes #27707 Closes #27710 Closes #27711 Closes #27727 Closes #27740 Closes #27744 Closes #27799 Closes #27801 cc #27801 (doesn't close as `Chars` is still unstable) Closes #28968
2015-11-18Add missing annotations and some testsVadim Petrochenkov-1/+3
2015-11-16Correct comment in `Mutex` exampleAndrew Paseltiner-1/+1
2015-10-16Add `Shared` pointer and have `{Arc, Rc}` use itAndrew Paseltiner-0/+1
This change has two consequences: 1. It makes `Arc<T>` and `Rc<T>` covariant in `T`. 2. It causes the compiler to reject code that was unsound with respect to dropck. See compile-fail/issue-29106.rs for an example of code that no longer compiles. Because of this, this is a [breaking-change]. Fixes #29037. Fixes #29106.
2015-10-15std: add into_inner and get_mut to mutexCristi Cobzarenco-0/+115
2015-09-20Miscellaneous cleanup for old issues.Lee Jeffery-12/+11
2015-09-08some more clippy-based improvementsAndre Bogus-2/+3
2015-08-15std: Add issues to all unstable featuresAlex Crichton-3/+6