Skip to content

Commit 7a978ac

Browse files
committed
---
yaml --- r: 34893 b: refs/heads/master c: b6bde88 h: refs/heads/master i: 34891: 60c2981 v: v3
1 parent 002b7d0 commit 7a978ac

File tree

2 files changed

+9
-38
lines changed

2 files changed

+9
-38
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 84c85496227e1b31f763dfd7e9a82c9b5da52407
2+
refs/heads/master: b6bde885dc276b2fab3dd0b2de98627dcc304026
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024

trunk/src/libcore/task.rs

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use cmp::Eq;
3232
use result::Result;
3333
use pipes::{stream, Chan, Port};
3434
use local_data_priv::{local_get, local_set};
35+
use util::replace;
3536

3637
use rt::task_id;
3738
use rt::rust_task;
@@ -246,11 +247,7 @@ priv impl TaskBuilder {
246247
fail ~"Cannot copy a task_builder"; // Fake move mode on self
247248
}
248249
self.consumed = true;
249-
let notify_chan = if self.opts.notify_chan.is_none() {
250-
None
251-
} else {
252-
Some(option::swap_unwrap(&mut self.opts.notify_chan))
253-
};
250+
let notify_chan = replace(&mut self.opts.notify_chan, None);
254251
TaskBuilder({
255252
opts: {
256253
linked: self.opts.linked,
@@ -271,11 +268,7 @@ impl TaskBuilder {
271268
* the other will not be killed.
272269
*/
273270
fn unlinked() -> TaskBuilder {
274-
let notify_chan = if self.opts.notify_chan.is_none() {
275-
None
276-
} else {
277-
Some(option::swap_unwrap(&mut self.opts.notify_chan))
278-
};
271+
let notify_chan = replace(&mut self.opts.notify_chan, None);
279272
TaskBuilder({
280273
opts: {
281274
linked: false,
@@ -293,11 +286,7 @@ impl TaskBuilder {
293286
* the child.
294287
*/
295288
fn supervised() -> TaskBuilder {
296-
let notify_chan = if self.opts.notify_chan.is_none() {
297-
None
298-
} else {
299-
Some(option::swap_unwrap(&mut self.opts.notify_chan))
300-
};
289+
let notify_chan = replace(&mut self.opts.notify_chan, None);
301290
TaskBuilder({
302291
opts: {
303292
linked: false,
@@ -314,11 +303,7 @@ impl TaskBuilder {
314303
* other will be killed.
315304
*/
316305
fn linked() -> TaskBuilder {
317-
let notify_chan = if self.opts.notify_chan.is_none() {
318-
None
319-
} else {
320-
Some(option::swap_unwrap(&mut self.opts.notify_chan))
321-
};
306+
let notify_chan = replace(&mut self.opts.notify_chan, None);
322307
TaskBuilder({
323308
opts: {
324309
linked: true,
@@ -381,11 +366,7 @@ impl TaskBuilder {
381366
}
382367
/// Configure a custom scheduler mode for the task.
383368
fn sched_mode(mode: SchedMode) -> TaskBuilder {
384-
let notify_chan = if self.opts.notify_chan.is_none() {
385-
None
386-
} else {
387-
Some(option::swap_unwrap(&mut self.opts.notify_chan))
388-
};
369+
let notify_chan = replace(&mut self.opts.notify_chan, None);
389370
TaskBuilder({
390371
opts: {
391372
linked: self.opts.linked,
@@ -412,11 +393,7 @@ impl TaskBuilder {
412393
*/
413394
fn add_wrapper(wrapper: fn@(v: fn~()) -> fn~()) -> TaskBuilder {
414395
let prev_gen_body = self.gen_body;
415-
let notify_chan = if self.opts.notify_chan.is_none() {
416-
None
417-
} else {
418-
Some(option::swap_unwrap(&mut self.opts.notify_chan))
419-
};
396+
let notify_chan = replace(&mut self.opts.notify_chan, None);
420397
TaskBuilder({
421398
opts: {
422399
linked: self.opts.linked,
@@ -447,13 +424,7 @@ impl TaskBuilder {
447424
* must be greater than zero.
448425
*/
449426
fn spawn(f: fn~()) {
450-
let notify_chan = if self.opts.notify_chan.is_none() {
451-
None
452-
} else {
453-
let swapped_notify_chan =
454-
option::swap_unwrap(&mut self.opts.notify_chan);
455-
Some(move swapped_notify_chan)
456-
};
427+
let notify_chan = replace(&mut self.opts.notify_chan, None);
457428
let x = self.consume();
458429
let opts = {
459430
linked: x.opts.linked,

0 commit comments

Comments
 (0)