Skip to content

Commit 6131325

Browse files
committed
wait on recv() channel
1 parent 0759efb commit 6131325

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ rust: nightly
33

44
script:
55
- cargo test -v
6-
#- cargo build --manifest-path benchmarks/Cargo.toml -v
6+
- cargo build --manifest-path benchmarks/Cargo.toml -v
7+
- cargo run --example simple
8+
- cargo run --example main_function
9+
- cargo run --example panic

src/runtime/processor.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use std::mem;
3030
use std::ptr;
3131
use std::sync::mpsc::{self, Receiver, Sender};
3232
use std::thread::{self, Builder};
33-
use std::time::Duration;
3433

3534
use deque::{BufferPool, Stolen, Worker, Stealer};
3635

@@ -330,10 +329,19 @@ impl Processor {
330329
}
331330
}
332331

333-
// This sleep throttles this loop in case a Processor runs out of work.
334-
// TODO: Replace this sleep by some mechanism capable of waking up
335-
// idle workers as soon as new work is available.
336-
thread::sleep(Duration::from_millis(10));
332+
// Wait forever until we got notified
333+
if let Ok(msg) = self.chan_receiver.recv() {
334+
match msg {
335+
ProcMessage::NewNeighbor(nei) => self.neighbor_stealers.push(nei),
336+
ProcMessage::Shutdown => {
337+
self.destroy_all_coroutines();
338+
}
339+
ProcMessage::Ready(SendableCoroutinePtr(ptr)) => {
340+
self.ready(ptr);
341+
self.has_ready_tasks = true;
342+
}
343+
}
344+
};
337345
}
338346

339347
self.is_scheduling = false;

0 commit comments

Comments
 (0)