about summary refs log tree commit diff
path: root/src/libstd/rt/comm.rs
diff options
context:
space:
mode:
authortoddaaro <github@opprobrio.us>2013-08-05 13:06:24 -0700
committertoddaaro <github@opprobrio.us>2013-08-08 14:13:41 -0700
commitaf2e03998d4d06f2781ca72ec005f6913148f8bb (patch)
treefc65de2220eb4735ef6fdf554b5c7204ec41d6b1 /src/libstd/rt/comm.rs
parenta0080f4e07891c89aa1f9851f8b0a3c754734fe8 (diff)
Enabled workstealing in the scheduler. Previously we had one global work queue shared by each scheduler. Now there is a separate work queue for each scheduler, and work is "stolen" from other queues when it is exhausted locally.
Diffstat (limited to 'src/libstd/rt/comm.rs')
-rw-r--r--src/libstd/rt/comm.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs
index 0cf223f3029..33b4b307af8 100644
--- a/src/libstd/rt/comm.rs
+++ b/src/libstd/rt/comm.rs
@@ -225,9 +225,10 @@ impl<T> Select for PortOne<T> {
     fn optimistic_check(&mut self) -> bool {
         // The optimistic check is never necessary for correctness. For testing
         // purposes, making it randomly return false simulates a racing sender.
-        use rand::{Rand, rng};
-        let mut rng = rng();
-        let actually_check = Rand::rand(&mut rng);
+        use rand::{Rand};
+        let actually_check = do Local::borrow::<Scheduler, bool> |sched| {
+            Rand::rand(&mut sched.rng)
+        };
         if actually_check {
             unsafe { (*self.packet()).state.load(Acquire) == STATE_ONE }
         } else {