about summary refs log tree commit diff
path: root/src/libstd/local_data.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-07-09 14:52:01 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-07-09 17:31:01 -0700
commit5c3a2e7eeb1e553c7fc06a012862d99094faa03f (patch)
treef6237ed53a3dc736b8facf5e5b270bf2e480096f /src/libstd/local_data.rs
parent692a22e69d916f8d0153ee9dfa906272561e364a (diff)
Change TLS to almost be able to contain owned types
Diffstat (limited to 'src/libstd/local_data.rs')
-rw-r--r--src/libstd/local_data.rs18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs
index fbb11dfaa34..77bbe4f5b97 100644
--- a/src/libstd/local_data.rs
+++ b/src/libstd/local_data.rs
@@ -46,33 +46,27 @@ use task::local_data_priv::{local_get, local_pop, local_set, Handle};
  *
  * These two cases aside, the interface is safe.
  */
-pub type LocalDataKey<'self,T> = &'self fn:Copy(v: @T);
+pub type LocalDataKey<'self,T> = &'self fn:Copy(v: T);
 
 /**
  * Remove a task-local data value from the table, returning the
  * reference that was originally created to insert it.
  */
-pub unsafe fn local_data_pop<T: 'static>(
-    key: LocalDataKey<T>) -> Option<@T> {
-
+pub unsafe fn local_data_pop<T: 'static>(key: LocalDataKey<T>) -> Option<T> {
     local_pop(Handle::new(), key)
 }
 /**
  * Retrieve a task-local data value. It will also be kept alive in the
  * table until explicitly removed.
  */
-pub unsafe fn local_data_get<T: 'static>(
-    key: LocalDataKey<T>) -> Option<@T> {
-
-    local_get(Handle::new(), key)
+pub unsafe fn local_data_get<T: 'static>(key: LocalDataKey<@T>) -> Option<@T> {
+    local_get(Handle::new(), key, |loc| loc.map(|&x| *x))
 }
 /**
  * Store a value in task-local data. If this key already has a value,
  * that value is overwritten (and its destructor is run).
  */
-pub unsafe fn local_data_set<T: 'static>(
-    key: LocalDataKey<T>, data: @T) {
-
+pub unsafe fn local_data_set<T: 'static>(key: LocalDataKey<@T>, data: @T) {
     local_set(Handle::new(), key, data)
 }
 /**
@@ -80,7 +74,7 @@ pub unsafe fn local_data_set<T: 'static>(
  * data is removed (and its reference dropped).
  */
 pub unsafe fn local_data_modify<T: 'static>(
-    key: LocalDataKey<T>,
+    key: LocalDataKey<@T>,
     modify_fn: &fn(Option<@T>) -> Option<@T>) {
 
     let cur = local_data_pop(key);