about summary refs log tree commit diff
path: root/src/libstd/sync/future.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-11-14 14:20:57 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-11-23 23:37:16 -0800
commita9c1152c4bf72132806cb76045b3464d59db07da (patch)
tree89ba92d5f5788e3323b75ca003bf74661a94e4de /src/libstd/sync/future.rs
parent4e5259503cd8aac9905c7ac6d68d0c4caab1d28c (diff)
downloadrust-a9c1152c4bf72132806cb76045b3464d59db07da.tar.gz
rust-a9c1152c4bf72132806cb76045b3464d59db07da.zip
std: Add a new top-level thread_local module
This commit removes the `std::local_data` module in favor of a new
`std::thread_local` module providing thread local storage. The module provides
two variants of TLS: one which owns its contents and one which is based on
scoped references. Each implementation has pros and cons listed in the
documentation.

Both flavors have accessors through a function called `with` which yield a
reference to a closure provided. Both flavors also panic if a reference cannot
be yielded and provide a function to test whether an access would panic or not.
This is an implementation of [RFC 461][rfc] and full details can be found in
that RFC.

This is a breaking change due to the removal of the `std::local_data` module.
All users can migrate to the new thread local system like so:

    thread_local!(static FOO: Rc<RefCell<Option<T>>> = Rc::new(RefCell::new(None)))

The old `local_data` module inherently contained the `Rc<RefCell<Option<T>>>` as
an implementation detail which must now be explicitly stated by users.

[rfc]: https://github.com/rust-lang/rfcs/pull/461
[breaking-change]
Diffstat (limited to 'src/libstd/sync/future.rs')
-rw-r--r--src/libstd/sync/future.rs24
1 files changed, 0 insertions, 24 deletions
diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs
index e37d1f83877..3e1ba8cebf8 100644
--- a/src/libstd/sync/future.rs
+++ b/src/libstd/sync/future.rs
@@ -210,28 +210,4 @@ mod test {
         });
         assert_eq!(rx.recv(), expected);
     }
-
-    #[test]
-    fn test_dropped_future_doesnt_panic() {
-        struct Bomb(Sender<bool>);
-
-        local_data_key!(LOCAL: Bomb)
-
-        impl Drop for Bomb {
-            fn drop(&mut self) {
-                let Bomb(ref tx) = *self;
-                tx.send(task::failing());
-            }
-        }
-
-        // Spawn a future, but drop it immediately. When we receive the result
-        // later on, we should never view the task as having panicked.
-        let (tx, rx) = channel();
-        drop(Future::spawn(proc() {
-            LOCAL.replace(Some(Bomb(tx)));
-        }));
-
-        // Make sure the future didn't panic the task.
-        assert!(!rx.recv());
-    }
 }