about summary refs log tree commit diff
path: root/src/libstd/rt/basic.rs
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-11-12 14:38:28 -0800
committerAlex Crichton <alex@alexcrichton.com>2013-11-13 18:34:59 -0800
commit9bcf557589a385d163c6d543ede82953b09e072f (patch)
treefa03002e7054bde23c9712637f78914806e16454 /src/libstd/rt/basic.rs
parent1bfa45cfd9d7c8b2dcc0ea7a42396624e8b5a31b (diff)
downloadrust-9bcf557589a385d163c6d543ede82953b09e072f.tar.gz
rust-9bcf557589a385d163c6d543ede82953b09e072f.zip
Implement native::IoFactory
This commit re-organizes the io::native module slightly in order to have a
working implementation of rtio::IoFactory which uses native implementations. The
goal is to seamlessly multiplex among libuv/native implementations wherever
necessary.

Right now most of the native I/O is unimplemented, but we have existing bindings
for file descriptors and processes which have been hooked up. What this means is
that you can now invoke println!() from libstd with no local task, no local
scheduler, and even without libuv.

There's still plenty of work to do on the native I/O factory, but this is the
first steps into making it an official portion of the standard library. I don't
expect anyone to reach into io::native directly, but rather only std::io
primitives will be used. Each std::io interface seamlessly falls back onto the
native I/O implementation if the local scheduler doesn't have a libuv one
(hurray trait ojects!)
Diffstat (limited to 'src/libstd/rt/basic.rs')
-rw-r--r--src/libstd/rt/basic.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libstd/rt/basic.rs b/src/libstd/rt/basic.rs
index a8f762c4c8f..42ecbf5dc78 100644
--- a/src/libstd/rt/basic.rs
+++ b/src/libstd/rt/basic.rs
@@ -18,6 +18,7 @@ use cast;
 use rt::rtio::{EventLoop, IoFactory, RemoteCallback, PausibleIdleCallback,
                Callback};
 use unstable::sync::Exclusive;
+use io::native;
 use util;
 
 /// This is the only exported function from this module.
@@ -30,7 +31,8 @@ struct BasicLoop {
     idle: Option<*mut BasicPausible>, // only one is allowed
     remotes: ~[(uint, ~Callback)],
     next_remote: uint,
-    messages: Exclusive<~[Message]>
+    messages: Exclusive<~[Message]>,
+    io: ~IoFactory,
 }
 
 enum Message { RunRemote(uint), RemoveRemote(uint) }
@@ -54,6 +56,7 @@ impl BasicLoop {
             next_remote: 0,
             remotes: ~[],
             messages: Exclusive::new(~[]),
+            io: ~native::IoFactory as ~IoFactory,
         }
     }
 
@@ -167,8 +170,9 @@ impl EventLoop for BasicLoop {
         ~BasicRemote::new(self.messages.clone(), id) as ~RemoteCallback
     }
 
-    /// This has no bindings for local I/O
-    fn io<'a>(&'a mut self, _: &fn(&'a mut IoFactory)) {}
+    fn io<'a>(&'a mut self, f: &fn(&'a mut IoFactory)) {
+        f(self.io)
+    }
 }
 
 struct BasicRemote {