Skip to content

Commit ab284d4

Browse files
committed
core::rt Restructure some modules
Put all uv code under rt::uv, as if it were in its own crate. Pull local_sched out of rt::sched.
1 parent 23bf892 commit ab284d4

File tree

10 files changed

+31
-29
lines changed

10 files changed

+31
-29
lines changed

src/libcore/rt/sched/local_sched.rs renamed to src/libcore/rt/local_sched.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ use libc::c_void;
1616
use cast;
1717
use cell::Cell;
1818

19-
use super::Scheduler;
20-
use super::super::rtio::IoFactoryObject;
21-
use tls = super::super::thread_local_storage;
19+
use rt::sched::Scheduler;
20+
use rt::rtio::{EventLoop, IoFactoryObject};
21+
use tls = rt::thread_local_storage;
2222
use unstable::finally::Finally;
2323

24-
#[cfg(test)] use super::super::uvio::UvEventLoop;
24+
#[cfg(test)] use rt::uv::uvio::UvEventLoop;
2525

2626
/// Give the Scheduler to thread-local storage
2727
pub fn put(sched: ~Scheduler) {

src/libcore/rt/mod.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121

2222
use libc::c_char;
2323

24-
/// The Scheduler and Task types, and thread-local access thereof
25-
#[path = "sched/mod.rs"]
24+
/// The Scheduler and Task types
2625
mod sched;
2726

27+
/// Thread-local access to the current Scheduler
28+
mod local_sched;
29+
2830
/// Synchronous I/O
2931
#[path = "io/mod.rs"]
3032
pub mod io;
@@ -39,14 +41,7 @@ mod rtio;
3941

4042
/// libuv
4143
#[path = "uv/mod.rs"]
42-
mod uv;
43-
44-
/// The implementation of `rtio` for libuv
45-
mod uvio;
46-
47-
/// C bindings to libuv
48-
pub mod uvll;
49-
44+
pub mod uv;
5045

5146
// FIXME #5248: The import in `sched` doesn't resolve unless this is pub!
5247
/// Bindings to pthread/windows thread-local storage
@@ -94,7 +89,7 @@ pub mod test;
9489
pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int {
9590

9691
use self::sched::{Scheduler, Task};
97-
use self::uvio::UvEventLoop;
92+
use self::uv::uvio::UvEventLoop;
9893
use sys::Closure;
9994
use ptr;
10095
use cast;
@@ -175,7 +170,7 @@ pub fn context() -> RuntimeContext {
175170
fn test_context() {
176171
use unstable::run_in_bare_thread;
177172
use self::sched::{local_sched, Task};
178-
use self::uvio::UvEventLoop;
173+
use rt::uv::uvio::UvEventLoop;
179174
use cell::Cell;
180175

181176
assert!(context() == OldTaskContext);

src/libcore/rt/rtio.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ use result::*;
1313

1414
use rt::io::IoError;
1515
use super::io::net::ip::IpAddr;
16+
use rt::uv::uvio;
1617

1718
// XXX: ~object doesn't work currently so these are some placeholder
1819
// types to use instead
19-
pub type EventLoopObject = super::uvio::UvEventLoop;
20-
pub type IoFactoryObject = super::uvio::UvIoFactory;
21-
pub type RtioTcpStreamObject = super::uvio::UvTcpStream;
22-
pub type RtioTcpListenerObject = super::uvio::UvTcpListener;
20+
pub type EventLoopObject = uvio::UvEventLoop;
21+
pub type IoFactoryObject = uvio::UvIoFactory;
22+
pub type RtioTcpStreamObject = uvio::UvTcpStream;
23+
pub type RtioTcpListenerObject = uvio::UvTcpListener;
2324

2425
pub trait EventLoop {
2526
fn run(&mut self);

src/libcore/rt/sched/mod.rs renamed to src/libcore/rt/sched.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use super::context::Context;
1919
use super::local_services::LocalServices;
2020
use cell::Cell;
2121

22-
#[cfg(test)] use super::uvio::UvEventLoop;
22+
#[cfg(test)] use rt::uv::uvio::UvEventLoop;
2323
#[cfg(test)] use unstable::run_in_bare_thread;
2424
#[cfg(test)] use int;
2525

src/libcore/rt/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rt::local_services::LocalServices;
1919
pub fn run_in_newsched_task(f: ~fn()) {
2020
use unstable::run_in_bare_thread;
2121
use super::sched::Task;
22-
use super::uvio::UvEventLoop;
22+
use rt::uv::uvio::UvEventLoop;
2323

2424
let f = Cell(f);
2525

src/libcore/rt/uv/file.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use prelude::*;
1212
use ptr::null;
1313
use libc::c_void;
1414
use super::{UvError, Callback, Request, NativeHandle, Loop};
15-
use super::super::uvll;
16-
use super::super::uvll::*;
15+
use rt::uv::uvll;
16+
use rt::uv::uvll::*;
1717

1818
pub type FsCallback = ~fn(FsRequest, Option<UvError>);
1919
impl Callback for FsCallback { }

src/libcore/rt/uv/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
/*!
1212
13-
Bindings to libuv.
13+
Bindings to libuv, along with the default implementation of `core::rt::rtio`.
1414
1515
UV types consist of the event loop (Loop), Watchers, Requests and
1616
Callbacks.
@@ -47,7 +47,6 @@ use cast::transmute;
4747
use ptr::null;
4848
use unstable::finally::Finally;
4949

50-
use rt::uvll;
5150
use rt::io::IoError;
5251

5352
#[cfg(test)] use unstable::run_in_bare_thread;
@@ -56,6 +55,13 @@ pub use self::file::{FsRequest, FsCallback};
5655
pub use self::net::{StreamWatcher, TcpWatcher};
5756
pub use self::net::{ReadCallback, AllocCallback, ConnectionCallback, ConnectCallback};
5857

58+
59+
/// The implementation of `rtio` for libuv
60+
pub mod uvio;
61+
62+
/// C bindings to libuv
63+
pub mod uvll;
64+
5965
pub mod file;
6066
pub mod net;
6167

@@ -240,7 +246,7 @@ pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
240246
241247
unsafe {
242248
// Importing error constants
243-
use rt::uvll::*;
249+
use rt::uv::uvll::*;
244250
use rt::io::*;
245251
246252
// uv error descriptions are static

src/libcore/rt/uv/net.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
use prelude::*;
1212
use libc::{size_t, ssize_t, c_int, c_void};
1313
use cast::transmute_mut_region;
14-
use super::super::uvll;
15-
use super::super::uvll::*;
14+
use rt::uv::uvll;
15+
use rt::uv::uvll::*;
1616
use super::{Loop, Watcher, Request, UvError, Buf, Callback, NativeHandle, NullCallback,
1717
loop_from_watcher, status_to_maybe_uv_error,
1818
install_watcher_data, get_watcher_data, drop_watcher_data,
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)