about summary refs log tree commit diff
path: root/src/libgreen
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-03-08 18:21:49 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-03-27 10:14:50 -0700
commitbb9172d7b512c36f34d34b024640f030d1fde2eb (patch)
tree0e4ea18ae30a12954db6b9fbe95f62222ade9301 /src/libgreen
parentbdd24b2a56e8bf6b952bd8880364fb0a57c2c540 (diff)
downloadrust-bb9172d7b512c36f34d34b024640f030d1fde2eb.tar.gz
rust-bb9172d7b512c36f34d34b024640f030d1fde2eb.zip
Fix fallout of removing default bounds
This is all purely fallout of getting the previous commit to compile.
Diffstat (limited to 'src/libgreen')
-rw-r--r--src/libgreen/basic.rs24
-rw-r--r--src/libgreen/lib.rs9
-rw-r--r--src/libgreen/sched.rs19
-rw-r--r--src/libgreen/simple.rs6
-rw-r--r--src/libgreen/task.rs5
5 files changed, 32 insertions, 31 deletions
diff --git a/src/libgreen/basic.rs b/src/libgreen/basic.rs
index b2596e56815..d2599aab14c 100644
--- a/src/libgreen/basic.rs
+++ b/src/libgreen/basic.rs
@@ -22,14 +22,14 @@ use std::rt::rtio::{EventLoop, IoFactory, RemoteCallback, PausableIdleCallback,
 use std::unstable::sync::Exclusive;
 
 /// This is the only exported function from this module.
-pub fn event_loop() -> ~EventLoop {
-    ~BasicLoop::new() as ~EventLoop
+pub fn event_loop() -> ~EventLoop:Send {
+    ~BasicLoop::new() as ~EventLoop:Send
 }
 
 struct BasicLoop {
-    work: ~[proc()],                  // pending work
+    work: ~[proc:Send()],             // pending work
     idle: Option<*mut BasicPausable>, // only one is allowed
-    remotes: ~[(uint, ~Callback)],
+    remotes: ~[(uint, ~Callback:Send)],
     next_remote: uint,
     messages: Exclusive<~[Message]>,
 }
@@ -135,26 +135,28 @@ impl EventLoop for BasicLoop {
         }
     }
 
-    fn callback(&mut self, f: proc()) {
+    fn callback(&mut self, f: proc:Send()) {
         self.work.push(f);
     }
 
     // FIXME: Seems like a really weird requirement to have an event loop provide.
-    fn pausable_idle_callback(&mut self, cb: ~Callback) -> ~PausableIdleCallback {
+    fn pausable_idle_callback(&mut self, cb: ~Callback:Send)
+        -> ~PausableIdleCallback:Send
+    {
         let callback = ~BasicPausable::new(self, cb);
         rtassert!(self.idle.is_none());
         unsafe {
             let cb_ptr: &*mut BasicPausable = cast::transmute(&callback);
             self.idle = Some(*cb_ptr);
         }
-        return callback as ~PausableIdleCallback;
+        callback as ~PausableIdleCallback:Send
     }
 
-    fn remote_callback(&mut self, f: ~Callback) -> ~RemoteCallback {
+    fn remote_callback(&mut self, f: ~Callback:Send) -> ~RemoteCallback:Send {
         let id = self.next_remote;
         self.next_remote += 1;
         self.remotes.push((id, f));
-        ~BasicRemote::new(self.messages.clone(), id) as ~RemoteCallback
+        ~BasicRemote::new(self.messages.clone(), id) as ~RemoteCallback:Send
     }
 
     fn io<'a>(&'a mut self) -> Option<&'a mut IoFactory> { None }
@@ -195,12 +197,12 @@ impl Drop for BasicRemote {
 
 struct BasicPausable {
     eloop: *mut BasicLoop,
-    work: ~Callback,
+    work: ~Callback:Send,
     active: bool,
 }
 
 impl BasicPausable {
-    fn new(eloop: &mut BasicLoop, cb: ~Callback) -> BasicPausable {
+    fn new(eloop: &mut BasicLoop, cb: ~Callback:Send) -> BasicPausable {
         BasicPausable {
             active: false,
             work: cb,
diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs
index 3f7685d6c20..12f2839f321 100644
--- a/src/libgreen/lib.rs
+++ b/src/libgreen/lib.rs
@@ -247,7 +247,7 @@ pub mod task;
 /// The return value is used as the process return code. 0 on success, 101 on
 /// error.
 pub fn start(argc: int, argv: **u8,
-             event_loop_factory: fn() -> ~rtio::EventLoop,
+             event_loop_factory: fn() -> ~rtio::EventLoop:Send,
              main: proc()) -> int {
     rt::init(argc, argv);
     let mut main = Some(main);
@@ -268,7 +268,8 @@ pub fn start(argc: int, argv: **u8,
 ///
 /// This function will not return until all schedulers in the associated pool
 /// have returned.
-pub fn run(event_loop_factory: fn() -> ~rtio::EventLoop, main: proc()) -> int {
+pub fn run(event_loop_factory: fn() -> ~rtio::EventLoop:Send,
+           main: proc()) -> int {
     // Create a scheduler pool and spawn the main task into this pool. We will
     // get notified over a channel when the main task exits.
     let mut cfg = PoolConfig::new();
@@ -298,7 +299,7 @@ pub struct PoolConfig {
     threads: uint,
     /// A factory function used to create new event loops. If this is not
     /// specified then the default event loop factory is used.
-    event_loop_factory: fn() -> ~rtio::EventLoop,
+    event_loop_factory: fn() -> ~rtio::EventLoop:Send,
 }
 
 impl PoolConfig {
@@ -323,7 +324,7 @@ pub struct SchedPool {
     priv stack_pool: StackPool,
     priv deque_pool: deque::BufferPool<~task::GreenTask>,
     priv sleepers: SleeperList,
-    priv factory: fn() -> ~rtio::EventLoop,
+    priv factory: fn() -> ~rtio::EventLoop:Send,
     priv task_state: TaskState,
     priv tasks_done: Receiver<()>,
 }
diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs
index 5571d4f4687..4308c05716c 100644
--- a/src/libgreen/sched.rs
+++ b/src/libgreen/sched.rs
@@ -79,7 +79,7 @@ pub struct Scheduler {
     /// A fast XorShift rng for scheduler use
     rng: XorShiftRng,
     /// A togglable idle callback
-    idle_callback: Option<~PausableIdleCallback>,
+    idle_callback: Option<~PausableIdleCallback:Send>,
     /// A countdown that starts at a random value and is decremented
     /// every time a yield check is performed. When it hits 0 a task
     /// will yield.
@@ -99,7 +99,7 @@ pub struct Scheduler {
     //      destroyed before it's actually destroyed.
 
     /// The event loop used to drive the scheduler and perform I/O
-    event_loop: ~EventLoop,
+    event_loop: ~EventLoop:Send,
 }
 
 /// An indication of how hard to work on a given operation, the difference
@@ -122,7 +122,7 @@ impl Scheduler {
     // * Initialization Functions
 
     pub fn new(pool_id: uint,
-               event_loop: ~EventLoop,
+               event_loop: ~EventLoop:Send,
                work_queue: deque::Worker<~GreenTask>,
                work_queues: ~[deque::Stealer<~GreenTask>],
                sleeper_list: SleeperList,
@@ -135,7 +135,7 @@ impl Scheduler {
     }
 
     pub fn new_special(pool_id: uint,
-                       event_loop: ~EventLoop,
+                       event_loop: ~EventLoop:Send,
                        work_queue: deque::Worker<~GreenTask>,
                        work_queues: ~[deque::Stealer<~GreenTask>],
                        sleeper_list: SleeperList,
@@ -182,7 +182,7 @@ impl Scheduler {
     pub fn bootstrap(mut ~self) {
 
         // Build an Idle callback.
-        let cb = ~SchedRunner as ~Callback;
+        let cb = ~SchedRunner as ~Callback:Send;
         self.idle_callback = Some(self.event_loop.pausable_idle_callback(cb));
 
         // Create a task for the scheduler with an empty context.
@@ -230,7 +230,7 @@ impl Scheduler {
         // mutable reference to the event_loop to give it the "run"
         // command.
         unsafe {
-            let event_loop: *mut ~EventLoop = &mut self.event_loop;
+            let event_loop: *mut ~EventLoop:Send = &mut self.event_loop;
             // Our scheduler must be in the task before the event loop
             // is started.
             stask.put_with_sched(self);
@@ -868,7 +868,7 @@ impl Scheduler {
     }
 
     pub fn make_handle(&mut self) -> SchedHandle {
-        let remote = self.event_loop.remote_callback(~SchedRunner as ~Callback);
+        let remote = self.event_loop.remote_callback(~SchedRunner);
 
         return SchedHandle {
             remote: remote,
@@ -893,7 +893,7 @@ pub enum SchedMessage {
 }
 
 pub struct SchedHandle {
-    priv remote: ~RemoteCallback,
+    priv remote: ~RemoteCallback:Send,
     priv queue: msgq::Producer<SchedMessage>,
     sched_id: uint
 }
@@ -1007,7 +1007,6 @@ mod test {
 
     use std::comm;
     use std::task::TaskOpts;
-    use std::rt::Runtime;
     use std::rt::task::Task;
     use std::rt::local::Local;
 
@@ -1034,7 +1033,7 @@ mod test {
         match task.get().maybe_take_runtime::<GreenTask>() {
             Some(green) => {
                 let ret = green.sched.get_ref().sched_id();
-                task.get().put_runtime(green as ~Runtime);
+                task.get().put_runtime(green);
                 return ret;
             }
             None => fail!()
diff --git a/src/libgreen/simple.rs b/src/libgreen/simple.rs
index 01e620df2d6..75a53b0bbd3 100644
--- a/src/libgreen/simple.rs
+++ b/src/libgreen/simple.rs
@@ -34,7 +34,7 @@ impl Runtime for SimpleTask {
 
         let me = &mut *self as *mut SimpleTask;
         let cur_dupe = &*cur_task as *Task;
-        cur_task.put_runtime(self as ~Runtime);
+        cur_task.put_runtime(self);
         let task = BlockedTask::block(cur_task);
 
         // See libnative/task.rs for what's going on here with the `awoken`
@@ -57,7 +57,7 @@ impl Runtime for SimpleTask {
     }
     fn reawaken(mut ~self, mut to_wake: ~Task) {
         let me = &mut *self as *mut SimpleTask;
-        to_wake.put_runtime(self as ~Runtime);
+        to_wake.put_runtime(self);
         unsafe {
             cast::forget(to_wake);
             let guard = (*me).lock.lock();
@@ -86,6 +86,6 @@ pub fn task() -> ~Task {
     task.put_runtime(~SimpleTask {
         lock: unsafe {NativeMutex::new()},
         awoken: false,
-    } as ~Runtime);
+    });
     return task;
 }
diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs
index 25e868470bf..7be749791a2 100644
--- a/src/libgreen/task.rs
+++ b/src/libgreen/task.rs
@@ -287,7 +287,7 @@ impl GreenTask {
 
     pub fn swap(mut ~self) -> ~Task {
         let mut task = self.task.take_unwrap();
-        task.put_runtime(self as ~Runtime);
+        task.put_runtime(self);
         return task;
     }
 
@@ -482,7 +482,6 @@ impl Runtime for GreenTask {
 
 #[cfg(test)]
 mod tests {
-    use std::rt::Runtime;
     use std::rt::local::Local;
     use std::rt::task::Task;
     use std::task;
@@ -576,7 +575,7 @@ mod tests {
                 let mut task: ~Task = Local::take();
                 match task.maybe_take_runtime::<GreenTask>() {
                     Some(ops) => {
-                        task.put_runtime(ops as ~Runtime);
+                        task.put_runtime(ops);
                     }
                     None => fail!(),
                 }