Skip to content

Commit a0bda5b

Browse files
committed
---
yaml --- r: 145733 b: refs/heads/try2 c: 49ac6ba h: refs/heads/master i: 145731: 0547f82 v: v3
1 parent 0841230 commit a0bda5b

File tree

6 files changed

+78
-7
lines changed

6 files changed

+78
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 1506dac10faf4b48f3d3debb9b20f2f55352deca
8+
refs/heads/try2: 49ac6baa726988c7a84dff3bdc8c1f8812940224
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/rt/task.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use rt::context::Context;
3333
use unstable::finally::Finally;
3434
use task::spawn::Taskgroup;
3535
use cell::Cell;
36+
use send_str::SendStr;
3637

3738
// The Task struct represents all state associated with a rust
3839
// task. There are at this point two primary "subtypes" of task,
@@ -49,8 +50,7 @@ pub struct Task {
4950
taskgroup: Option<Taskgroup>,
5051
death: Death,
5152
destroyed: bool,
52-
// FIXME(#6874/#7599) use StringRef to save on allocations
53-
name: Option<~str>,
53+
name: Option<SendStr>,
5454
coroutine: Option<Coroutine>,
5555
sched: Option<~Scheduler>,
5656
task_type: TaskType,

branches/try2/src/libstd/task/mod.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ use rt::in_green_task_context;
6363
use rt::local::Local;
6464
use unstable::finally::Finally;
6565
use util;
66+
use send_str::{SendStr, IntoSendStr};
6667

6768
#[cfg(test)] use cast;
6869
#[cfg(test)] use comm::SharedChan;
@@ -148,7 +149,7 @@ pub struct TaskOpts {
148149
watched: bool,
149150
indestructible: bool,
150151
notify_chan: Option<Chan<TaskResult>>,
151-
name: Option<~str>,
152+
name: Option<SendStr>,
152153
sched: SchedOpts,
153154
stack_size: Option<uint>
154155
}
@@ -295,8 +296,8 @@ impl TaskBuilder {
295296

296297
/// Name the task-to-be. Currently the name is used for identification
297298
/// only in failure messages.
298-
pub fn name(&mut self, name: ~str) {
299-
self.opts.name = Some(name);
299+
pub fn name<S: IntoSendStr>(&mut self, name: S) {
300+
self.opts.name = Some(name.into_send_str());
300301
}
301302

302303
/// Configure a custom scheduler mode for the task.
@@ -944,7 +945,7 @@ fn test_unnamed_task() {
944945
}
945946

946947
#[test]
947-
fn test_named_task() {
948+
fn test_owned_named_task() {
948949
use rt::test::run_in_newsched_task;
949950

950951
do run_in_newsched_task {
@@ -958,6 +959,21 @@ fn test_named_task() {
958959
}
959960
}
960961

962+
#[test]
963+
fn test_static_named_task() {
964+
use rt::test::run_in_newsched_task;
965+
966+
do run_in_newsched_task {
967+
let mut t = task();
968+
t.name("ada lovelace");
969+
do t.spawn {
970+
do with_task_name |name| {
971+
assert!(name.unwrap() == "ada lovelace");
972+
}
973+
}
974+
}
975+
}
976+
961977
#[test]
962978
fn test_run_basic() {
963979
let (po, ch) = stream::<()>();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:task '<unnamed>' failed at 'test'
12+
13+
fn main() {
14+
do spawn {
15+
fail2!("test");
16+
}
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:task 'owned name' failed at 'test'
12+
13+
fn main() {
14+
let mut t = ::std::task::task();
15+
t.name(~"owned name");
16+
do t.spawn {
17+
fail2!("test");
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:task 'static name' failed at 'test'
12+
13+
fn main() {
14+
let mut t = ::std::task::task();
15+
t.name("static name");
16+
do t.spawn {
17+
fail2!("test");
18+
}
19+
}

0 commit comments

Comments
 (0)