Skip to content

Commit 3e6cc98

Browse files
committed
---
yaml --- r: 146019 b: refs/heads/try2 c: 0ae9e47 h: refs/heads/master i: 146017: 79a1984 146015: 9cd8a86 v: v3
1 parent 8469e64 commit 3e6cc98

File tree

18 files changed

+98
-65
lines changed

18 files changed

+98
-65
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: a1848bc755411285afb15f2453df7567e10ebc04
8+
refs/heads/try2: 0ae9e476afb3647f7d71498795165e0e7fd85f02
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: Patrick Walton <[email protected]>
44
" Maintainer: Ben Blum <[email protected]>
55
" Maintainer: Chris Morgan <[email protected]>
6-
" Last Change: 2013 Sep 4
6+
" Last Change: 2013 Oct 19
77

88
if version < 600
99
syntax clear
@@ -61,6 +61,7 @@ syn keyword rustEnumVariant Ok Err
6161
" Functions {{{3
6262
"syn keyword rustFunction print println
6363
"syn keyword rustFunction range
64+
"syn keyword rustFunction from_str
6465

6566
" Types and traits {{{3
6667
syn keyword rustTrait ToCStr
@@ -79,22 +80,23 @@ syn keyword rustTrait Orderable Signed Unsigned Round
7980
syn keyword rustTrait Algebraic Trigonometric Exponential Hyperbolic
8081
syn keyword rustTrait Integer Fractional Real RealExt
8182
syn keyword rustTrait Bitwise BitCount Bounded
82-
syn keyword rustTrait Primitive Int Float ToStrRadix
83+
syn keyword rustTrait Primitive Int Float ToStrRadix ToPrimitive FromPrimitive
8384
syn keyword rustTrait GenericPath
8485
syn keyword rustTrait Path
8586
syn keyword rustTrait PosixPath
8687
syn keyword rustTrait WindowsPath
8788
syn keyword rustTrait RawPtr
8889
syn keyword rustTrait Ascii AsciiCast OwnedAsciiCast AsciiStr ToBytesConsume
90+
syn keyword rustTrait SendStr SendStrOwned SendStrStatic IntoSendStr
8991
syn keyword rustTrait Str StrVector StrSlice OwnedStr
9092
syn keyword rustTrait FromStr
9193
syn keyword rustTrait IterBytes
9294
syn keyword rustTrait ToStr ToStrConsume
9395
syn keyword rustTrait CopyableTuple ImmutableTuple
94-
syn keyword rustTrait CloneableTuple1 ImmutableTuple1
95-
syn keyword rustTrait CloneableTuple2 CloneableTuple3 CloneableTuple4 CloneableTuple5
96-
syn keyword rustTrait CloneableTuple6 CloneableTuple7 CloneableTuple8 CloneableTuple9
97-
syn keyword rustTrait CloneableTuple10 CloneableTuple11 CloneableTuple12
96+
syn keyword rustTrait Tuple1 ImmutableTuple1
97+
syn keyword rustTrait Tuple2 Tuple3 Tuple4 Tuple5
98+
syn keyword rustTrait Tuple6 Tuple7 Tuple8 Tuple9
99+
syn keyword rustTrait Tuple10 Tuple11 Tuple12
98100
syn keyword rustTrait ImmutableTuple2 ImmutableTuple3 ImmutableTuple4 ImmutableTuple5
99101
syn keyword rustTrait ImmutableTuple6 ImmutableTuple7 ImmutableTuple8 ImmutableTuple9
100102
syn keyword rustTrait ImmutableTuple10 ImmutableTuple11 ImmutableTuple12

branches/try2/src/libextra/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ mod tests {
823823
do 5.times {
824824
let arc3 = arc.clone();
825825
let mut builder = task::task();
826-
children.push(builder.future_result());
826+
builder.future_result(|r| children.push(r));
827827
do builder.spawn {
828828
do arc3.read |num| {
829829
assert!(*num >= 0);

branches/try2/src/libextra/test.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,12 +870,14 @@ pub fn run_test(force_ignore: bool,
870870
testfn: ~fn()) {
871871
let testfn_cell = ::std::cell::Cell::new(testfn);
872872
do task::spawn {
873+
let mut result_future = None; // task::future_result(builder);
874+
873875
let mut task = task::task();
874876
task.unlinked();
875-
let result_future = task.future_result();
877+
task.future_result(|r| { result_future = Some(r) });
876878
task.spawn(testfn_cell.take());
877879

878-
let task_result = result_future.recv();
880+
let task_result = result_future.unwrap().recv();
879881
let test_result = calc_result(&desc,
880882
task_result == task::Success);
881883
monitor_ch.send((desc.clone(), test_result));

branches/try2/src/libextra/url.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -671,13 +671,9 @@ pub fn to_str(url: &Url) -> ~str {
671671
};
672672

673673
let authority = if url.host.is_empty() {
674-
// If port is Some, we're in a nonsensical situation. Too bad.
675674
~""
676675
} else {
677-
match url.port {
678-
Some(ref port) => format!("//{}{}:{}", user, url.host, *port),
679-
None => format!("//{}{}", user, url.host),
680-
}
676+
format!("//{}{}", user, url.host)
681677
};
682678

683679
let query = if url.query.is_empty() {
@@ -899,12 +895,6 @@ mod tests {
899895
assert_eq!(from_str(url).unwrap().to_str(), url);
900896
}
901897

902-
#[test]
903-
fn test_url_with_port_parse_and_format() {
904-
let url = ~"http://rust-lang.org:80/doc";
905-
assert_eq!(from_str(url).unwrap().to_str(), url);
906-
}
907-
908898
#[test]
909899
fn test_scheme_host_only_url_parse_and_format() {
910900
let url = ~"http://rust-lang.org";

branches/try2/src/libstd/result.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ mod tests {
463463
use str::OwnedStr;
464464
use vec::ImmutableVector;
465465
use to_str::ToStr;
466+
use fmt::Default;
466467

467468
pub fn op1() -> Result<int, ~str> { Ok(666) }
468469
pub fn op2() -> Result<int, ~str> { Err(~"sadface") }

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,4 +621,29 @@ mod test {
621621
a.next = Some(b);
622622
}
623623
}
624+
625+
// XXX: This is a copy of test_future_result in std::task.
626+
// It can be removed once the scheduler is turned on by default.
627+
#[test]
628+
fn future_result() {
629+
do run_in_newsched_task {
630+
use option::{Some, None};
631+
use task::*;
632+
633+
let mut result = None;
634+
let mut builder = task();
635+
builder.future_result(|r| result = Some(r));
636+
do builder.spawn {}
637+
assert_eq!(result.unwrap().recv(), Success);
638+
639+
result = None;
640+
let mut builder = task();
641+
builder.future_result(|r| result = Some(r));
642+
builder.unlinked();
643+
do builder.spawn {
644+
fail2!();
645+
}
646+
assert_eq!(result.unwrap().recv(), Failure);
647+
}
648+
}
624649
}

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

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -258,22 +258,24 @@ impl TaskBuilder {
258258
self.opts.indestructible = true;
259259
}
260260

261-
/// Get a future representing the exit status of the task.
262-
///
263-
/// Taking the value of the future will block until the child task
264-
/// terminates. The future result return value will be created *before* the task is
265-
/// spawned; as such, do not invoke .get() on it directly;
266-
/// rather, store it in an outer variable/list for later use.
267-
///
268-
/// Note that the future returned by this function is only useful for
269-
/// obtaining the value of the next task to be spawning with the
270-
/// builder. If additional tasks are spawned with the same builder
271-
/// then a new result future must be obtained prior to spawning each
272-
/// task.
273-
///
274-
/// # Failure
275-
/// Fails if a future_result was already set for this task.
276-
pub fn future_result(&mut self) -> Port<TaskResult> {
261+
/**
262+
* Get a future representing the exit status of the task.
263+
*
264+
* Taking the value of the future will block until the child task
265+
* terminates. The future-receiving callback specified will be called
266+
* *before* the task is spawned; as such, do not invoke .get() within the
267+
* closure; rather, store it in an outer variable/list for later use.
268+
*
269+
* Note that the future returning by this function is only useful for
270+
* obtaining the value of the next task to be spawning with the
271+
* builder. If additional tasks are spawned with the same builder
272+
* then a new result future must be obtained prior to spawning each
273+
* task.
274+
*
275+
* # Failure
276+
* Fails if a future_result was already set for this task.
277+
*/
278+
pub fn future_result(&mut self, blk: &fn(v: Port<TaskResult>)) {
277279
// FIXME (#3725): Once linked failure and notification are
278280
// handled in the library, I can imagine implementing this by just
279281
// registering an arbitrary number of task::on_exit handlers and
@@ -286,10 +288,10 @@ impl TaskBuilder {
286288
// Construct the future and give it to the caller.
287289
let (notify_pipe_po, notify_pipe_ch) = stream::<TaskResult>();
288290

291+
blk(notify_pipe_po);
292+
289293
// Reconfigure self to use a notify channel.
290294
self.opts.notify_chan = Some(notify_pipe_ch);
291-
292-
notify_pipe_po
293295
}
294296

295297
/// Name the task-to-be. Currently the name is used for identification
@@ -396,14 +398,15 @@ impl TaskBuilder {
396398
*/
397399
pub fn try<T:Send>(&mut self, f: ~fn() -> T) -> Result<T,()> {
398400
let (po, ch) = stream::<T>();
401+
let mut result = None;
399402

400-
let result = self.future_result();
403+
self.future_result(|r| { result = Some(r); });
401404

402405
do self.spawn {
403406
ch.send(f());
404407
}
405408

406-
match result.recv() {
409+
match result.unwrap().recv() {
407410
Success => result::Ok(po.recv()),
408411
Failure => result::Err(())
409412
}
@@ -1021,25 +1024,27 @@ fn test_add_wrapper() {
10211024

10221025
#[test]
10231026
fn test_future_result() {
1027+
let mut result = None;
10241028
let mut builder = task();
1025-
let result = builder.future_result();
1029+
builder.future_result(|r| result = Some(r));
10261030
do builder.spawn {}
1027-
assert_eq!(result.recv(), Success);
1031+
assert_eq!(result.unwrap().recv(), Success);
10281032

1033+
result = None;
10291034
let mut builder = task();
1030-
let result = builder.future_result();
1035+
builder.future_result(|r| result = Some(r));
10311036
builder.unlinked();
10321037
do builder.spawn {
10331038
fail2!();
10341039
}
1035-
assert_eq!(result.recv(), Failure);
1040+
assert_eq!(result.unwrap().recv(), Failure);
10361041
}
10371042

10381043
#[test] #[should_fail]
10391044
fn test_back_to_the_future_result() {
10401045
let mut builder = task();
1041-
builder.future_result();
1042-
builder.future_result();
1046+
builder.future_result(util::ignore);
1047+
builder.future_result(util::ignore);
10431048
}
10441049

10451050
#[test]

branches/try2/src/libstd/unstable/sync.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,29 +580,32 @@ mod tests {
580580
// Now try the same thing, but with the child task blocking.
581581
let x = Exclusive::new(~~"hello");
582582
let x2 = Cell::new(x.clone());
583+
let mut res = None;
583584
let mut builder = task::task();
584-
let res = builder.future_result();
585+
builder.future_result(|r| res = Some(r));
585586
do builder.spawn {
586587
let x2 = x2.take();
587588
assert!(x2.unwrap() == ~~"hello");
588589
}
589590
// Have to get rid of our reference before blocking.
590591
util::ignore(x);
591-
res.recv();
592+
res.unwrap().recv();
592593
}
593594
594595
#[test] #[should_fail]
595596
fn exclusive_new_unwrap_conflict() {
596597
let x = Exclusive::new(~~"hello");
597598
let x2 = Cell::new(x.clone());
599+
let mut res = None;
598600
let mut builder = task::task();
599-
let res = builder.future_result();
601+
builder.future_result(|r| res = Some(r));
600602
do builder.spawn {
601603
let x2 = x2.take();
602604
assert!(x2.unwrap() == ~~"hello");
603605
}
604606
assert!(x.unwrap() == ~~"hello");
605-
assert!(res.recv() == task::Success);
607+
// See #4689 for why this can't be just "res.recv()".
608+
assert!(res.unwrap().recv() == task::Success);
606609
}
607610
608611
#[test]

branches/try2/src/test/bench/msgsend-pipes-shared.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fn run(args: &[~str]) {
6767
for _ in range(0u, workers) {
6868
let to_child = to_child.clone();
6969
let mut builder = task::task();
70-
worker_results.push(builder.future_result());
70+
builder.future_result(|r| worker_results.push(r));
7171
do builder.spawn {
7272
for _ in range(0u, size / workers) {
7373
//error2!("worker {:?}: sending {:?} bytes", i, num_bytes);

branches/try2/src/test/bench/msgsend-pipes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn run(args: &[~str]) {
6161
for _ in range(0u, workers) {
6262
let to_child = to_child.clone();
6363
let mut builder = task::task();
64-
worker_results.push(builder.future_result());
64+
builder.future_result(|r| worker_results.push(r));
6565
do builder.spawn {
6666
for _ in range(0u, size / workers) {
6767
//error2!("worker {:?}: sending {:?} bytes", i, num_bytes);

branches/try2/src/test/bench/shootout-pfib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn stress(num_tasks: int) {
8484
let mut results = ~[];
8585
for i in range(0, num_tasks) {
8686
let mut builder = task::task();
87-
results.push(builder.future_result());
87+
builder.future_result(|r| results.push(r));
8888
do builder.spawn {
8989
stress_task(i);
9090
}

branches/try2/src/test/bench/task-perf-linked-failure.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ fn grandchild_group(num_tasks: uint) {
5454
}
5555

5656
fn spawn_supervised_blocking(myname: &str, f: ~fn()) {
57+
let mut res = None;
5758
let mut builder = task::task();
58-
let res = builder.future_result();
59+
builder.future_result(|r| res = Some(r));
5960
builder.supervised();
6061
builder.spawn(f);
6162
error2!("{} group waiting", myname);
62-
let x = res.recv();
63+
let x = res.unwrap().recv();
6364
assert_eq!(x, task::Success);
6465
}
6566

branches/try2/src/test/run-pass/task-comm-12.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ fn start(_task_number: int) { info2!("Started / Finished task."); }
1818

1919
fn test00() {
2020
let i: int = 0;
21+
let mut result = None;
2122
let mut builder = task::task();
22-
let result = builder.future_result();
23+
builder.future_result(|r| result = Some(r));
2324
do builder.spawn {
2425
start(i)
2526
}
@@ -32,7 +33,7 @@ fn test00() {
3233
}
3334

3435
// Try joining tasks that have already finished.
35-
result.recv();
36+
result.unwrap().recv();
3637

3738
info2!("Joined task.");
3839
}

branches/try2/src/test/run-pass/task-comm-3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn test00() {
4545
while i < number_of_tasks {
4646
let ch = ch.clone();
4747
let mut builder = task::task();
48-
results.push(builder.future_result());
48+
builder.future_result(|r| results.push(r));
4949
builder.spawn({
5050
let i = i;
5151
|| test00_start(&ch, i, number_of_messages)

branches/try2/src/test/run-pass/task-comm-9.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ fn test00() {
2828
let (p, ch) = comm::stream();
2929
let number_of_messages: int = 10;
3030

31+
let mut result = None;
3132
let mut builder = task::task();
32-
let result = builder.future_result();
33+
builder.future_result(|r| result = Some(r));
3334
do builder.spawn {
3435
test00_start(&ch, number_of_messages);
3536
}
@@ -41,7 +42,7 @@ fn test00() {
4142
i += 1;
4243
}
4344

44-
result.recv();
45+
result.unwrap().recv();
4546

4647
assert_eq!(sum, number_of_messages * (number_of_messages - 1) / 2);
4748
}

0 commit comments

Comments
 (0)