about summary refs log tree commit diff
path: root/src/libstd/thread
diff options
context:
space:
mode:
authorDenys Zariaiev <denys.zariaiev@gmail.com>2019-03-13 21:00:45 +0100
committerDenys Zariaiev <denys.zariaiev@gmail.com>2019-03-13 21:00:45 +0100
commiteeb5f171da2486c34e4e473c97a1468279d05e7c (patch)
treeb452442f799d5d62141419e7091de13c212de9ff /src/libstd/thread
parent5c7ec6c421af26666d3ec1c5fe022d099133951c (diff)
parent8bf1f1c8f4100247c1f9b3d9b7aecea5c970263e (diff)
downloadrust-eeb5f171da2486c34e4e473c97a1468279d05e7c.tar.gz
rust-eeb5f171da2486c34e4e473c97a1468279d05e7c.zip
Merge remote-tracking branch 'upstream/master' into asm-compile-tests
Diffstat (limited to 'src/libstd/thread')
-rw-r--r--src/libstd/thread/local.rs59
-rw-r--r--src/libstd/thread/mod.rs58
2 files changed, 58 insertions, 59 deletions
diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs
index 8207709e1f9..7ad6b124e3a 100644
--- a/src/libstd/thread/local.rs
+++ b/src/libstd/thread/local.rs
@@ -2,10 +2,10 @@
 
 #![unstable(feature = "thread_local_internals", issue = "0")]
 
-use cell::UnsafeCell;
-use fmt;
-use hint;
-use mem;
+use crate::cell::UnsafeCell;
+use crate::fmt;
+use crate::hint;
+use crate::mem;
 
 /// A thread local storage key which owns its contents.
 ///
@@ -40,13 +40,16 @@ use mem;
 /// });
 ///
 /// // each thread starts out with the initial value of 1
-/// thread::spawn(move|| {
+/// let t = thread::spawn(move|| {
 ///     FOO.with(|f| {
 ///         assert_eq!(*f.borrow(), 1);
 ///         *f.borrow_mut() = 3;
 ///     });
 /// });
 ///
+/// // wait for the thread to complete and bail out on panic
+/// t.join().unwrap();
+///
 /// // we retain our original value of 2 despite the child thread
 /// FOO.with(|f| {
 ///     assert_eq!(*f.borrow(), 2);
@@ -126,8 +129,7 @@ impl<T: 'static> fmt::Debug for LocalKey<T> {
 /// [`std::thread::LocalKey`]: ../std/thread/struct.LocalKey.html
 #[macro_export]
 #[stable(feature = "rust1", since = "1.0.0")]
-#[cfg_attr(stage0, allow_internal_unstable)]
-#[cfg_attr(not(stage0), allow_internal_unstable(thread_local_internals))]
+#[allow_internal_unstable(thread_local_internals)]
 macro_rules! thread_local {
     // empty (base case for the recursion)
     () => {};
@@ -149,10 +151,7 @@ macro_rules! thread_local {
            reason = "should not be necessary",
            issue = "0")]
 #[macro_export]
-#[cfg_attr(stage0, allow_internal_unstable)]
-#[cfg_attr(not(stage0), allow_internal_unstable(
-    thread_local_internals, cfg_target_thread_local, thread_local,
-))]
+#[allow_internal_unstable(thread_local_internals, cfg_target_thread_local, thread_local)]
 #[allow_internal_unsafe]
 macro_rules! __thread_local_inner {
     (@key $(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $init:expr) => {
@@ -310,14 +309,14 @@ impl<T: 'static> LocalKey<T> {
 #[doc(hidden)]
 #[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))]
 pub mod statik {
-    use cell::UnsafeCell;
-    use fmt;
+    use crate::cell::UnsafeCell;
+    use crate::fmt;
 
     pub struct Key<T> {
         inner: UnsafeCell<Option<T>>,
     }
 
-    unsafe impl<T> ::marker::Sync for Key<T> { }
+    unsafe impl<T> Sync for Key<T> { }
 
     impl<T> fmt::Debug for Key<T> {
         fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -341,11 +340,11 @@ pub mod statik {
 #[doc(hidden)]
 #[cfg(target_thread_local)]
 pub mod fast {
-    use cell::{Cell, UnsafeCell};
-    use fmt;
-    use mem;
-    use ptr;
-    use sys::fast_thread_local::{register_dtor, requires_move_before_drop};
+    use crate::cell::{Cell, UnsafeCell};
+    use crate::fmt;
+    use crate::mem;
+    use crate::ptr;
+    use crate::sys::fast_thread_local::{register_dtor, requires_move_before_drop};
 
     pub struct Key<T> {
         inner: UnsafeCell<Option<T>>,
@@ -412,11 +411,11 @@ pub mod fast {
 
 #[doc(hidden)]
 pub mod os {
-    use cell::{Cell, UnsafeCell};
-    use fmt;
-    use marker;
-    use ptr;
-    use sys_common::thread_local::StaticKey as OsStaticKey;
+    use crate::cell::{Cell, UnsafeCell};
+    use crate::fmt;
+    use crate::marker;
+    use crate::ptr;
+    use crate::sys_common::thread_local::StaticKey as OsStaticKey;
 
     pub struct Key<T> {
         // OS-TLS key that we'll use to key off.
@@ -430,7 +429,7 @@ pub mod os {
         }
     }
 
-    unsafe impl<T> ::marker::Sync for Key<T> { }
+    unsafe impl<T> Sync for Key<T> { }
 
     struct Value<T: 'static> {
         key: &'static Key<T>,
@@ -484,9 +483,9 @@ pub mod os {
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
-    use sync::mpsc::{channel, Sender};
-    use cell::{Cell, UnsafeCell};
-    use thread;
+    use crate::sync::mpsc::{channel, Sender};
+    use crate::cell::{Cell, UnsafeCell};
+    use crate::thread;
 
     struct Foo(Sender<()>);
 
@@ -632,8 +631,8 @@ mod tests {
 
 #[cfg(test)]
 mod dynamic_tests {
-    use cell::RefCell;
-    use collections::HashMap;
+    use crate::cell::RefCell;
+    use crate::collections::HashMap;
 
     #[test]
     fn smoke() {
diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs
index 438ea3aa3f6..08f0aa2f0d2 100644
--- a/src/libstd/thread/mod.rs
+++ b/src/libstd/thread/mod.rs
@@ -156,25 +156,25 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use any::Any;
-use boxed::FnBox;
-use cell::UnsafeCell;
-use ffi::{CStr, CString};
-use fmt;
-use io;
-use mem;
-use panic;
-use panicking;
-use str;
-use sync::{Mutex, Condvar, Arc};
-use sync::atomic::AtomicUsize;
-use sync::atomic::Ordering::SeqCst;
-use sys::thread as imp;
-use sys_common::mutex;
-use sys_common::thread_info;
-use sys_common::thread;
-use sys_common::{AsInner, IntoInner};
-use time::Duration;
+use crate::any::Any;
+use crate::boxed::FnBox;
+use crate::cell::UnsafeCell;
+use crate::ffi::{CStr, CString};
+use crate::fmt;
+use crate::io;
+use crate::mem;
+use crate::panic;
+use crate::panicking;
+use crate::str;
+use crate::sync::{Mutex, Condvar, Arc};
+use crate::sync::atomic::AtomicUsize;
+use crate::sync::atomic::Ordering::SeqCst;
+use crate::sys::thread as imp;
+use crate::sys_common::mutex;
+use crate::sys_common::thread_info;
+use crate::sys_common::thread;
+use crate::sys_common::{AsInner, IntoInner};
+use crate::time::Duration;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Thread-local storage
@@ -466,7 +466,7 @@ impl Builder {
             thread_info::set(imp::guard::current(), their_thread);
             #[cfg(feature = "backtrace")]
             let try_result = panic::catch_unwind(panic::AssertUnwindSafe(|| {
-                ::sys_common::backtrace::__rust_begin_short_backtrace(f)
+                crate::sys_common::backtrace::__rust_begin_short_backtrace(f)
             }));
             #[cfg(not(feature = "backtrace"))]
             let try_result = panic::catch_unwind(panic::AssertUnwindSafe(f));
@@ -1051,7 +1051,7 @@ impl ThreadId {
 
             // If we somehow use up all our bits, panic so that we're not
             // covering up subtle bugs of IDs being reused.
-            if COUNTER == ::u64::MAX {
+            if COUNTER == crate::u64::MAX {
                 panic!("failed to generate unique thread ID: bitspace exhausted");
             }
 
@@ -1290,7 +1290,7 @@ impl fmt::Debug for Thread {
 ///
 /// [`Result`]: ../../std/result/enum.Result.html
 #[stable(feature = "rust1", since = "1.0.0")]
-pub type Result<T> = ::result::Result<T, Box<dyn Any + Send + 'static>>;
+pub type Result<T> = crate::result::Result<T, Box<dyn Any + Send + 'static>>;
 
 // This packet is used to communicate the return value between the child thread
 // and the parent thread. Memory is shared through the `Arc` within and there's
@@ -1482,13 +1482,13 @@ fn _assert_sync_and_send() {
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
-    use any::Any;
-    use sync::mpsc::{channel, Sender};
-    use result;
-    use super::{Builder};
-    use thread;
-    use time::Duration;
-    use u32;
+    use super::Builder;
+    use crate::any::Any;
+    use crate::sync::mpsc::{channel, Sender};
+    use crate::result;
+    use crate::thread;
+    use crate::time::Duration;
+    use crate::u32;
 
     // !!! These tests are dangerous. If something is buggy, they will hang, !!!
     // !!! instead of exiting cleanly. This might wedge the buildbots.       !!!