diff options
| author | bors <bors@rust-lang.org> | 2013-07-11 19:52:37 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-07-11 19:52:37 -0700 |
| commit | 07183ea6e719e18f5d6b09afbe519c9f940c4705 (patch) | |
| tree | e7d78b7be38a4f9e3763c08cfdd9569a45be6d6f /src/libstd/task/spawn.rs | |
| parent | 9a9c84fb8362c26f24b1ea8443a509047f27b38f (diff) | |
| parent | a15c1b4464099fa65ec5da389381db83c22801ec (diff) | |
| download | rust-07183ea6e719e18f5d6b09afbe519c9f940c4705.tar.gz rust-07183ea6e719e18f5d6b09afbe519c9f940c4705.zip | |
auto merge of #7677 : alexcrichton/rust/tls-gc, r=pcwalton
cc #6004 and #3273 This is a rewrite of TLS to get towards not requiring `@` when using task local storage. Most of the rewrite is straightforward, although there are two caveats: 1. Changing `local_set` to not require `@` is blocked on #7673 2. The code in `local_pop` is some of the most unsafe code I've written. A second set of eyes should definitely scrutinize it... The public-facing interface currently hasn't changed, although it will have to change because `local_data::get` cannot return `Option<T>`, nor can it return `Option<&T>` (the lifetime isn't known). This will have to be changed to be given a closure which yield `&T` (or as an Option). I didn't do this part of the api rewrite in this pull request as I figured that it could wait until when `@` is fully removed. This also doesn't deal with the issue of using something other than functions as keys, but I'm looking into using static slices (as mentioned in the issues).
Diffstat (limited to 'src/libstd/task/spawn.rs')
| -rw-r--r-- | src/libstd/task/spawn.rs | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs index bcb7e06bf1f..f45d470a9f6 100644 --- a/src/libstd/task/spawn.rs +++ b/src/libstd/task/spawn.rs @@ -478,26 +478,28 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) * Step 1. Get spawner's taskgroup info. *##################################################################*/ let spawner_group: @@mut TCB = - match local_get(OldHandle(spawner), taskgroup_key!()) { - None => { - // Main task, doing first spawn ever. Lazily initialise - // here. - let mut members = new_taskset(); - taskset_insert(&mut members, spawner); - let tasks = exclusive(Some(TaskGroupData { - members: members, - descendants: new_taskset(), - })); - // Main task/group has no ancestors, no notifier, etc. - let group = @@mut TCB(spawner, - tasks, - AncestorList(None), - true, - None); - local_set(OldHandle(spawner), taskgroup_key!(), group); - group + do local_get(OldHandle(spawner), taskgroup_key!()) |group| { + match group { + None => { + // Main task, doing first spawn ever. Lazily initialise + // here. + let mut members = new_taskset(); + taskset_insert(&mut members, spawner); + let tasks = exclusive(Some(TaskGroupData { + members: members, + descendants: new_taskset(), + })); + // Main task/group has no ancestors, no notifier, etc. + let group = @@mut TCB(spawner, + tasks, + AncestorList(None), + true, + None); + local_set(OldHandle(spawner), taskgroup_key!(), group); + group + } + Some(&group) => group } - Some(group) => group }; let spawner_group: &mut TCB = *spawner_group; |
