@@ -63,6 +63,7 @@ use rt::in_green_task_context;
63
63
use rt:: local:: Local ;
64
64
use unstable:: finally:: Finally ;
65
65
use util;
66
+ use send_str:: { SendStr , IntoSendStr } ;
66
67
67
68
#[ cfg( test) ] use cast;
68
69
#[ cfg( test) ] use comm:: SharedChan ;
@@ -148,7 +149,7 @@ pub struct TaskOpts {
148
149
watched : bool ,
149
150
indestructible : bool ,
150
151
notify_chan : Option < Chan < TaskResult > > ,
151
- name : Option < ~ str > ,
152
+ name : Option < SendStr > ,
152
153
sched : SchedOpts ,
153
154
stack_size : Option < uint >
154
155
}
@@ -295,8 +296,8 @@ impl TaskBuilder {
295
296
296
297
/// Name the task-to-be. Currently the name is used for identification
297
298
/// 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 ( ) ) ;
300
301
}
301
302
302
303
/// Configure a custom scheduler mode for the task.
@@ -944,7 +945,7 @@ fn test_unnamed_task() {
944
945
}
945
946
946
947
#[ test]
947
- fn test_named_task ( ) {
948
+ fn test_owned_named_task ( ) {
948
949
use rt:: test:: run_in_newsched_task;
949
950
950
951
do run_in_newsched_task {
@@ -958,6 +959,36 @@ fn test_named_task() {
958
959
}
959
960
}
960
961
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
+
977
+ #[ test]
978
+ fn test_send_named_task ( ) {
979
+ use rt:: test:: run_in_newsched_task;
980
+
981
+ do run_in_newsched_task {
982
+ let mut t = task ( ) ;
983
+ t. name ( "ada lovelace" . into_send_str ( ) ) ;
984
+ do t. spawn {
985
+ do with_task_name |name| {
986
+ assert ! ( name. unwrap( ) == "ada lovelace" ) ;
987
+ }
988
+ }
989
+ }
990
+ }
991
+
961
992
#[ test]
962
993
fn test_run_basic ( ) {
963
994
let ( po, ch) = stream :: < ( ) > ( ) ;
0 commit comments