Skip to content
This repository has been archived by the owner on Mar 15, 2023. It is now read-only.

Commit

Permalink
Update for rust changes
Browse files Browse the repository at this point in the history
  • Loading branch information
am0d committed Dec 17, 2014
1 parent 8b8478d commit 4fd57aa
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion first/hello-multithreaded.rs
Expand Up @@ -6,7 +6,7 @@ fn main () {

for child_number in range(0, 20i) {
let child_sender = sender.clone();
spawn(proc() {
spawn(move || {
child_sender.send(child_number);
});
}
Expand Down
4 changes: 2 additions & 2 deletions first/prime-sieve.rs
Expand Up @@ -24,7 +24,7 @@ fn main() {

let mut prev_receiver = receiver;

spawn(proc() {
spawn(move || {
generate(&sender);
});

Expand All @@ -35,7 +35,7 @@ fn main() {
let (new_sender, new_receiver) = channel();
let prev_receiver_cell = RefCell::new(prev_receiver);

spawn(proc() {
spawn(move || {
filter(&prev_receiver_cell.unwrap(), &new_sender, prime);
});
prev_receiver = new_receiver;
Expand Down
1 change: 1 addition & 0 deletions sorting/Makefile
@@ -1,4 +1,5 @@
all:
@cargo update
@cargo build

clean:
Expand Down
4 changes: 2 additions & 2 deletions sorting/src/bin/merge-sort-par.rs
Expand Up @@ -28,9 +28,9 @@ fn parallel_merge_sort<T:Ord+Clone+Send>(arr: Vec<T>, depth: uint, max_threads:
/* Create channel to pass the results back */
let (sender, receiver) = channel();
let left_cell = RefCell::new(left); // the only way to access the above mutable field
spawn(proc() {
spawn(move || {
// take the ref out of the cell, sort it, and send it back to the parent process
let sorted_left = parallel_merge_sort(left_cell.unwrap(), depth + 1, max_threads);
let sorted_left = parallel_merge_sort(left_cell.into_inner(), depth + 1, max_threads);
sender.send(sorted_left);
});
right = parallel_merge_sort(right, depth + 1, max_threads);
Expand Down
5 changes: 3 additions & 2 deletions sorting/src/lib.rs
Expand Up @@ -9,6 +9,7 @@ use timer::Timer;

pub mod timer;

#[deriving(Copy)]
pub struct Benchmark {
num_trials: uint,
trial_size: uint,
Expand Down Expand Up @@ -39,8 +40,8 @@ impl Benchmark {
optflag("h", "help", "Show this help")
];
let matches = match getopts(args.tail(), opts) {
result::Ok(m) => { m }
result::Err(f) => { panic!(f.to_string()) }
result::Result::Ok(m) => { m }
result::Result::Err(f) => { panic!(f.to_string()) }
};
if matches.opt_present("h") || matches.opt_present("help") {
let brief = format!("Usage: {} [options]", args.as_slice().head().map(|x| x.as_slice()).unwrap_or(""));
Expand Down
1 change: 1 addition & 0 deletions sorting/src/timer.rs
Expand Up @@ -4,6 +4,7 @@ const SEC_MULTIPLIER:u64 = 1000 * 1000 * 1000;
const MIN_MULTIPLIER:u64 = 60 * SEC_MULTIPLIER;
const HR_MULTIPLIER:u64 = 60 * MIN_MULTIPLIER;

#[deriving(Copy)]
pub struct Timer {
start_time: u64,
end_time: u64
Expand Down

0 comments on commit 4fd57aa

Please sign in to comment.