Skip to content

Commit 3cb54b9

Browse files
committed
---
yaml --- r: 141311 b: refs/heads/try2 c: 67283ea h: refs/heads/master i: 141309: bb18b75 141307: 4dc484a 141303: 4c54b9c 141295: c8db5a6 141279: 58cac24 141247: 286968c 141183: 5ed487b 141055: 821b6ee 140799: 6f00978 140287: 29fb8da 139263: 8878be9 v: v3
1 parent c7e8f12 commit 3cb54b9

File tree

140 files changed

+621
-929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+621
-929
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: 5676056ae6dd3a10d2c7323375ace3ca2fe1c308
8+
refs/heads/try2: 67283eaad2f53e19ae963e2b0a04b65826568336
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/configure

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,11 @@ then
555555
CFG_CLANG_VERSION=$("$CFG_CLANG" \
556556
--version \
557557
| grep version \
558-
| sed 's/.*\(version .*\)/\1/; s/.*based on \(LLVM .*\))/\1/' \
558+
| sed 's/.*\(version .*\)/\1/' \
559559
| cut -d ' ' -f 2)
560560

561561
case $CFG_CLANG_VERSION in
562-
(3.0svn | 3.0 | 3.1* | 3.2* | 3.3*)
562+
(3.0svn | 3.0 | 3.1* | 3.2* | 3.3* | 4.0* | 4.1* | 4.2*)
563563
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
564564
CFG_C_COMPILER="clang"
565565
;;

branches/try2/doc/tutorial-tasks.md

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ let result = ports.foldl(0, |accum, port| *accum + port.recv() );
284284
# fn some_expensive_computation(_i: uint) -> int { 42 }
285285
~~~
286286

287-
## Backgrounding computations: Futures
287+
## Futures
288288
With `extra::future`, rust has a mechanism for requesting a computation and getting the result
289289
later.
290290

@@ -329,77 +329,6 @@ fn main() {
329329
}
330330
~~~
331331

332-
## Sharing immutable data without copy: ARC
333-
334-
To share immutable data between tasks, a first approach would be to only use pipes as we have seen
335-
previously. A copy of the data to share would then be made for each task. In some cases, this would
336-
add up to a significant amount of wasted memory and would require copying the same data more than
337-
necessary.
338-
339-
To tackle this issue, one can use an Atomically Reference Counted wrapper (`ARC`) as implemented in
340-
the `extra` library of Rust. With an ARC, the data will no longer be copied for each task. The ARC
341-
acts as a reference to the shared data and only this reference is shared and cloned.
342-
343-
Here is a small example showing how to use ARCs. We wish to run concurrently several computations on
344-
a single large vector of floats. Each task needs the full vector to perform its duty.
345-
~~~
346-
use extra::arc::ARC;
347-
348-
fn pnorm(nums: &~[float], p: uint) -> float {
349-
(vec::foldl(0.0, *nums, |a,b| a+(*b).pow(p as float) )).pow(1f / (p as float))
350-
}
351-
352-
fn main() {
353-
let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
354-
println(fmt!("Inf-norm = %?", numbers.max()));
355-
356-
let numbers_arc = ARC(numbers);
357-
358-
for uint::range(1,10) |num| {
359-
let (port, chan) = stream();
360-
chan.send(numbers_arc.clone());
361-
362-
do spawn {
363-
let local_arc : ARC<~[float]> = port.recv();
364-
let task_numbers = local_arc.get();
365-
println(fmt!("%u-norm = %?", num, pnorm(task_numbers, num)));
366-
}
367-
}
368-
}
369-
~~~
370-
371-
The function `pnorm` performs a simple computation on the vector (it computes the sum of its items
372-
at the power given as argument and takes the inverse power of this value). The ARC on the vector is
373-
created by the line
374-
~~~
375-
# use extra::arc::ARC;
376-
# let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
377-
let numbers_arc=ARC(numbers);
378-
~~~
379-
and a clone of it is sent to each task
380-
~~~
381-
# use extra::arc::ARC;
382-
# let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
383-
# let numbers_arc = ARC(numbers);
384-
# let (port, chan) = stream();
385-
chan.send(numbers_arc.clone());
386-
~~~
387-
copying only the wrapper and not its contents.
388-
389-
Each task recovers the underlying data by
390-
~~~
391-
# use extra::arc::ARC;
392-
# let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
393-
# let numbers_arc=ARC(numbers);
394-
# let (port, chan) = stream();
395-
# chan.send(numbers_arc.clone());
396-
# let local_arc : ARC<~[float]> = port.recv();
397-
let task_numbers = local_arc.get();
398-
~~~
399-
and can use it as if it were local.
400-
401-
The `arc` module also implements ARCs around mutable data that are not covered here.
402-
403332
# Handling task failure
404333

405334
Rust has a built-in mechanism for raising exceptions. The `fail!()` macro

branches/try2/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ define TEST_RUNNER
284284
# If NO_REBUILD is set then break the dependencies on extra so we can
285285
# test crates without rebuilding std and extra first
286286
ifeq ($(NO_REBUILD),)
287-
STDTESTDEP_$(1)_$(2)_$(3) = $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_EXTRALIB_$(2))
287+
STDTESTDEP_$(1)_$(2)_$(3) = $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB_$(2))
288288
else
289289
STDTESTDEP_$(1)_$(2)_$(3) =
290290
endif
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"Highlight the 100th text column
2+
"Feature became available in v7.3
3+
if version >= 703
4+
setlocal colorcolumn=100
5+
endif

branches/try2/src/libextra/arc.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* In this example, a large vector of floats is shared between several tasks.
1818
* With simple pipes, without ARC, a copy would have to be made for each task.
1919
*
20-
* ~~~ {.rust}
20+
* ~~~
2121
* extern mod std;
2222
* use std::arc;
2323
* let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random());
@@ -370,10 +370,7 @@ pub impl<T:Const + Owned> RWARC<T> {
370370
* See sync::rwlock.write_downgrade(). The RWWriteMode token must be used
371371
* to obtain the &mut T, and can be transformed into a RWReadMode token by
372372
* calling downgrade(), after which a &T can be obtained instead.
373-
*
374-
* # Example
375-
*
376-
* ~~~ {.rust}
373+
* ~~~
377374
* do arc.write_downgrade |write_mode| {
378375
* do (&write_mode).write_cond |state, condvar| {
379376
* ... exclusive access with mutable state ...
@@ -510,6 +507,7 @@ mod tests {
510507
use core::prelude::*;
511508
use core::cell::Cell;
512509
use arc::*;
510+
use arc;
513511

514512
#[test]
515513
fn manually_share_arc() {

branches/try2/src/libextra/base64.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ impl<'self> ToBase64 for &'self [u8] {
2828
/**
2929
* Turn a vector of `u8` bytes into a base64 string.
3030
*
31-
* # Example
31+
* *Example*:
3232
*
33-
* ~~~ {.rust}
33+
* ~~~~
3434
* extern mod std;
3535
* use std::base64::ToBase64;
3636
*
3737
* fn main () {
3838
* let str = [52,32].to_base64();
3939
* println(fmt!("%s", str));
4040
* }
41-
* ~~~
41+
* ~~~~
4242
*/
4343
fn to_base64(&self) -> ~str {
4444
let mut s = ~"";
@@ -91,17 +91,17 @@ impl<'self> ToBase64 for &'self str {
9191
* Convert any string (literal, `@`, `&`, or `~`) to base64 encoding.
9292
*
9393
*
94-
* # Example
94+
* *Example*:
9595
*
96-
* ~~~ {.rust}
96+
* ~~~~
9797
* extern mod std;
9898
* use std::base64::ToBase64;
9999
*
100100
* fn main () {
101101
* let str = "Hello, World".to_base64();
102102
* println(fmt!("%s",str));
103103
* }
104-
* ~~~
104+
* ~~~~
105105
*
106106
*/
107107
fn to_base64(&self) -> ~str {
@@ -118,9 +118,9 @@ impl FromBase64 for ~[u8] {
118118
* Convert base64 `u8` vector into u8 byte values.
119119
* Every 4 encoded characters is converted into 3 octets, modulo padding.
120120
*
121-
* # Example
121+
* *Example*:
122122
*
123-
* ~~~ {.rust}
123+
* ~~~~
124124
* extern mod std;
125125
* use std::base64::ToBase64;
126126
* use std::base64::FromBase64;
@@ -131,7 +131,7 @@ impl FromBase64 for ~[u8] {
131131
* let bytes = str.from_base64();
132132
* println(fmt!("%?",bytes));
133133
* }
134-
* ~~~
134+
* ~~~~
135135
*/
136136
fn from_base64(&self) -> ~[u8] {
137137
if self.len() % 4u != 0u { fail!("invalid base64 length"); }
@@ -196,11 +196,11 @@ impl FromBase64 for ~str {
196196
* You can use the `from_bytes` function in `core::str`
197197
* to turn a `[u8]` into a string with characters corresponding to those values.
198198
*
199-
* # Example
199+
* *Example*:
200200
*
201201
* This converts a string literal to base64 and back.
202202
*
203-
* ~~~ {.rust}
203+
* ~~~~
204204
* extern mod std;
205205
* use std::base64::ToBase64;
206206
* use std::base64::FromBase64;
@@ -214,7 +214,7 @@ impl FromBase64 for ~str {
214214
* let result_str = str::from_bytes(bytes);
215215
* println(fmt!("%s",result_str));
216216
* }
217-
* ~~~
217+
* ~~~~
218218
*/
219219
fn from_base64(&self) -> ~[u8] {
220220
str::to_bytes(*self).from_base64()

branches/try2/src/libextra/bitv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ mod tests {
11971197
#[test]
11981198
fn test_from_bytes() {
11991199
let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]);
1200-
let str = ~"10110110" + "00000000" + "11111111";
1200+
let str = ~"10110110" + ~"00000000" + ~"11111111";
12011201
assert_eq!(bitv.to_str(), str);
12021202
}
12031203

branches/try2/src/libextra/deque.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -125,31 +125,6 @@ pub impl<T> Deque<T> {
125125
self.hi = (self.hi + 1u) % self.elts.len();
126126
self.nelts += 1u;
127127
}
128-
129-
/// Reserve capacity for exactly `n` elements in the given deque,
130-
/// doing nothing if `self`'s capacity is already equal to or greater
131-
/// than the requested capacity
132-
///
133-
/// # Arguments
134-
///
135-
/// * n - The number of elements to reserve space for
136-
fn reserve(&mut self, n: uint) {
137-
vec::reserve(&mut self.elts, n);
138-
}
139-
140-
/// Reserve capacity for at least `n` elements in the given deque,
141-
/// over-allocating in case the caller needs to reserve additional
142-
/// space.
143-
///
144-
/// Do nothing if `self`'s capacity is already equal to or greater
145-
/// than the requested capacity.
146-
///
147-
/// # Arguments
148-
///
149-
/// * n - The number of elements to reserve space for
150-
fn reserve_at_least(&mut self, n: uint) {
151-
vec::reserve_at_least(&mut self.elts, n);
152-
}
153128
}
154129

155130
/// Grow is only called on full elts, so nelts is also len(elts), unlike
@@ -174,7 +149,6 @@ mod tests {
174149
use super::*;
175150
use core::cmp::Eq;
176151
use core::kinds::Copy;
177-
use core::vec::capacity;
178152

179153
#[test]
180154
fn test_simple() {
@@ -354,29 +328,4 @@ mod tests {
354328
}
355329

356330
}
357-
358-
#[test]
359-
fn test_reserve() {
360-
let mut d = Deque::new();
361-
d.add_back(0u64);
362-
d.reserve(50);
363-
assert_eq!(capacity(&mut d.elts), 50);
364-
let mut d = Deque::new();
365-
d.add_back(0u32);
366-
d.reserve(50);
367-
assert_eq!(capacity(&mut d.elts), 50);
368-
}
369-
370-
#[test]
371-
fn test_reserve_at_least() {
372-
let mut d = Deque::new();
373-
d.add_back(0u64);
374-
d.reserve_at_least(50);
375-
assert_eq!(capacity(&mut d.elts), 64);
376-
let mut d = Deque::new();
377-
d.add_back(0u32);
378-
d.reserve_at_least(50);
379-
assert_eq!(capacity(&mut d.elts), 64);
380-
}
381-
382331
}

branches/try2/src/libextra/flatpipes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ports and channels.
2525
2626
This example sends boxed integers across tasks using serialization.
2727
28-
~~~ {.rust}
28+
~~~
2929
let (port, chan) = serial::pipe_stream();
3030
3131
do task::spawn || {
@@ -927,7 +927,7 @@ mod test {
927927
fn test_try_recv_none3<P:BytePort>(loader: PortLoader<P>) {
928928
static CONTINUE: [u8, ..4] = [0xAA, 0xBB, 0xCC, 0xDD];
929929
// The control word is followed by garbage
930-
let bytes = CONTINUE.to_vec() + [0];
930+
let bytes = CONTINUE.to_vec() + ~[0];
931931
let port = loader(bytes);
932932
let res: Option<int> = port.try_recv();
933933
assert!(res.is_none());
@@ -951,7 +951,7 @@ mod test {
951951
1, sys::size_of::<u64>()) |len_bytes| {
952952
len_bytes.to_vec()
953953
};
954-
let bytes = CONTINUE.to_vec() + len_bytes + [0, 0, 0, 0];
954+
let bytes = CONTINUE.to_vec() + len_bytes + ~[0, 0, 0, 0];
955955

956956
let port = loader(bytes);
957957

branches/try2/src/libextra/future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* # Example
1616
*
17-
* ~~~ {.rust}
17+
* ~~~
1818
* # fn fib(n: uint) -> uint {42};
1919
* # fn make_a_sandwich() {};
2020
* let mut delayed_fib = std::future::spawn (|| fib(5000) );

branches/try2/src/libextra/json.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,13 +1880,13 @@ mod tests {
18801880
]));
18811881
assert_eq!(result::unwrap(from_str(
18821882
~"{" +
1883-
"\"a\": 1.0, " +
1884-
"\"b\": [" +
1885-
"true," +
1886-
"\"foo\\nbar\", " +
1887-
"{ \"c\": {\"d\": null} } " +
1888-
"]" +
1889-
"}")),
1883+
~"\"a\": 1.0, " +
1884+
~"\"b\": [" +
1885+
~"true," +
1886+
~"\"foo\\nbar\", " +
1887+
~"{ \"c\": {\"d\": null} } " +
1888+
~"]" +
1889+
~"}")),
18901890
mk_object([
18911891
(~"a", Number(1.0f)),
18921892
(~"b", List(~[

branches/try2/src/libextra/net_ip.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ mod test {
375375
use uv;
376376

377377
use core::result;
378+
use core::vec;
378379

379380
#[test]
380381
fn test_ip_ipv4_parse_and_format_ip() {

0 commit comments

Comments
 (0)