about summary refs log tree commit diff
path: root/src/libcore/rt
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2013-04-10 13:11:35 -0700
committerNiko Matsakis <niko@alum.mit.edu>2013-04-10 17:32:03 -0700
commit61b9e0ebfa7c96886c45a461c6d8edb22f8153da (patch)
treef392a8f4119df4569328a228c994be2c4392d10a /src/libcore/rt
parent49de82cdca2064a909d3104f4e5eccacb0425fd0 (diff)
downloadrust-61b9e0ebfa7c96886c45a461c6d8edb22f8153da.tar.gz
rust-61b9e0ebfa7c96886c45a461c6d8edb22f8153da.zip
core: changes in response to #5656
Diffstat (limited to 'src/libcore/rt')
-rw-r--r--src/libcore/rt/rtio.rs5
-rw-r--r--src/libcore/rt/sched.rs40
-rw-r--r--src/libcore/rt/uvio.rs16
3 files changed, 61 insertions, 0 deletions
diff --git a/src/libcore/rt/rtio.rs b/src/libcore/rt/rtio.rs
index 55e062de85b..6a7c3970c00 100644
--- a/src/libcore/rt/rtio.rs
+++ b/src/libcore/rt/rtio.rs
@@ -22,7 +22,12 @@ pub trait EventLoop {
     fn run(&mut self);
     fn callback(&mut self, ~fn());
     /// The asynchronous I/O services. Not all event loops may provide one
+    #[cfg(stage0)]
     fn io(&mut self) -> Option<&'self mut IoFactoryObject>;
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    #[cfg(stage3)]
+    fn io<'a>(&'a mut self) -> Option<&'a mut IoFactoryObject>;
 }
 
 pub trait IoFactory {
diff --git a/src/libcore/rt/sched.rs b/src/libcore/rt/sched.rs
index 46ea5713e2a..25f446fb86d 100644
--- a/src/libcore/rt/sched.rs
+++ b/src/libcore/rt/sched.rs
@@ -272,6 +272,7 @@ pub impl Scheduler {
 
     // XXX: Hack. This should return &'self mut but I don't know how to
     // make the borrowcheck happy
+    #[cfg(stage0)]
     fn task_from_last_cleanup_job(&mut self) -> &mut Task {
         assert!(!self.cleanup_jobs.is_empty());
         let last_job: &'self mut CleanupJob = &mut self.cleanup_jobs[0];
@@ -285,6 +286,25 @@ pub impl Scheduler {
         // borrows
         return unsafe { transmute::<&Task, &mut Task>(last_task) };
     }
+
+    // XXX: Hack. This should return &'self mut but I don't know how to
+    // make the borrowcheck happy
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    #[cfg(stage3)]
+    fn task_from_last_cleanup_job<'a>(&'a mut self) -> &mut Task {
+        assert!(!self.cleanup_jobs.is_empty());
+        let last_job: &'a mut CleanupJob = &mut self.cleanup_jobs[0];
+        let last_task: &'a Task = match last_job {
+            &RescheduleTask(~ref task) => task,
+            &RecycleTask(~ref task) => task,
+            &GiveTask(~ref task, _) => task,
+        };
+        // XXX: Pattern matching mutable pointers above doesn't work
+        // because borrowck thinks the three patterns are conflicting
+        // borrows
+        return unsafe { transmute::<&Task, &mut Task>(last_task) };
+    }
 }
 
 static TASK_MIN_STACK_SIZE: uint = 10000000; // XXX: Too much stack
@@ -354,6 +374,7 @@ impl ThreadLocalScheduler {
         }
     }
 
+    #[cfg(stage0)]
     fn get_scheduler(&mut self) -> &'self mut Scheduler {
         unsafe {
             let key = match self { &ThreadLocalScheduler(key) => key };
@@ -370,6 +391,25 @@ impl ThreadLocalScheduler {
         }
     }
 
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    #[cfg(stage3)]
+    fn get_scheduler<'a>(&'a mut self) -> &'a mut Scheduler {
+        unsafe {
+            let key = match self { &ThreadLocalScheduler(key) => key };
+            let mut value: *mut c_void = tls::get(key);
+            assert!(value.is_not_null());
+            {
+                let value_ptr = &mut value;
+                let sched: &mut ~Scheduler = {
+                    transmute::<&mut *mut c_void, &mut ~Scheduler>(value_ptr)
+                };
+                let sched: &mut Scheduler = &mut **sched;
+                return sched;
+            }
+        }
+    }
+
     fn take_scheduler(&mut self) -> ~Scheduler {
         unsafe {
             let key = match self { &ThreadLocalScheduler(key) => key };
diff --git a/src/libcore/rt/uvio.rs b/src/libcore/rt/uvio.rs
index 37f29d1a5c0..7162ed27a9d 100644
--- a/src/libcore/rt/uvio.rs
+++ b/src/libcore/rt/uvio.rs
@@ -67,9 +67,17 @@ impl EventLoop for UvEventLoop {
         }
     }
 
+    #[cfg(stage0)]
     fn io(&mut self) -> Option<&'self mut IoFactoryObject> {
         Some(&mut self.uvio)
     }
+
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    #[cfg(stage3)]
+    fn io<'a>(&'a mut self) -> Option<&'a mut IoFactoryObject> {
+        Some(&mut self.uvio)
+    }
 }
 
 #[test]
@@ -89,9 +97,17 @@ fn test_callback_run_once() {
 pub struct UvIoFactory(Loop);
 
 pub impl UvIoFactory {
+    #[cfg(stage0)]
     fn uv_loop(&mut self) -> &'self mut Loop {
         match self { &UvIoFactory(ref mut ptr) => ptr }
     }
+
+    #[cfg(stage1)]
+    #[cfg(stage2)]
+    #[cfg(stage3)]
+    fn uv_loop<'a>(&'a mut self) -> &'a mut Loop {
+        match self { &UvIoFactory(ref mut ptr) => ptr }
+    }
 }
 
 impl IoFactory for UvIoFactory {