Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current scheduler and I/O work #6577

Closed
wants to merge 58 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
34be071
core::rt: Remove Close trait
brson Apr 25, 2013
0b4d4ed
core::rt: Fix a warning about unnecessary mutable variable
brson Apr 25, 2013
b2fbd34
core::rt: Begin implementing TcpStream
brson Apr 25, 2013
93ca5eb
core::rt: Clean up the interface to rtio
brson Apr 27, 2013
23bf892
core::rt: Improve docs
brson Apr 27, 2013
ab284d4
core::rt Restructure some modules
brson Apr 27, 2013
01b7b7d
core::rt: Use unsafe pointers instead of transmuted regions
brson Apr 27, 2013
b771c99
core::rt: Fix the finalizer on UvTcpStream and UvTcpListener
brson Apr 27, 2013
cfd183d
core::rt: Fix some copies in uv
brson Apr 28, 2013
6ab02c0
core::rt: Convert some uv functions to extension methods
brson Apr 28, 2013
91ca3a9
core::rt: Reording code
brson Apr 28, 2013
9138fea
core::rt: Only use one mechanism for attaching custom data to uv handles
brson Apr 28, 2013
dbf8966
core::rt: Move the implementation of IdleWatcher to its own file
brson Apr 28, 2013
a134503
core::rt: Move all the uv callback definitions to one place
brson Apr 28, 2013
ad6719e
core::rt: Just a small fix to TcpStream
brson May 3, 2013
10355d7
core::rt Wire up logging to newsched tasks
brson Apr 28, 2013
272c3c2
Tidy
brson May 3, 2013
936fce5
Warnings
brson May 3, 2013
40a9de5
core::rt: Add a very simple ref counted pointer
brson May 3, 2013
414f3c7
core::rt: Add a simple channel type for passing buffered messages bet…
brson May 5, 2013
d234cf7
core::rt: Make TCP servers work
brson May 6, 2013
101aaa3
core::rt: 0 is a valid TLS key
brson May 7, 2013
4472a50
rtdebug off
brson May 7, 2013
52f015a
core: Cleanup warnings
brson May 7, 2013
329dfca
core: Move unstable::exchange_alloc to rt::global_heap
brson May 7, 2013
f934fa7
core::rt: Docs
brson May 7, 2013
204e3d8
core::rt: Register stacks with valgrind. #6428
brson May 12, 2013
ee0ce64
core::rt: Wait for handles to close
brson May 12, 2013
b04fce6
Merge remote-tracking branch 'brson/io-upstream' into incoming
brson May 14, 2013
6a6076a
core::rt: Ignore tcp test multiple_connect_interleaved_lazy_schedule
brson May 15, 2013
bfd9aa9
core:rt: A few micro-opts
brson May 8, 2013
36ad366
core::rt: Add a test of standalone use of the runtime
brson May 8, 2013
f6401ba
core: Use a global lock instead of runtime lock for os::getenv, etc. …
brson May 8, 2013
cc2897d
core: Replace use of libc::getenv with os::getenv
brson May 8, 2013
0a54bad
core::rt: Initialize logging
brson May 8, 2013
174ec1e
core::rt: Error handling for TcpStream.read
brson May 9, 2013
afcf4f2
core::rt: Don't abort when reporting an unknown uv error
brson May 9, 2013
013b776
core: Turn task::unkillable, etc. into no-ops in newsched. #6377
brson May 10, 2013
b764d4c
core::rt: Begin implementing Reader extension methods
brson May 10, 2013
76e0977
core::rt: `read` raises `read_error`
brson May 13, 2013
4724966
core::rt: Add uv timer bindings
brson May 11, 2013
c42b03d
core::rt: Fix scheduling logic for enqueued tasks
brson May 11, 2013
56c0b18
rt: Rename sched_key to rt_key
brson May 12, 2013
7f5746f
core::rt: Rename Sched.task_queue to work_queue
brson May 12, 2013
390dde5
core::rt: Rename Task to Coroutine
brson May 12, 2013
1c1f11e
core::rt: Warnings
brson May 13, 2013
28a13ec
core::rt: Make push_bytes raise read_error on EOF
brson May 13, 2013
d45dc8d
core::rt: More work on Reader extensions and error handling
brson May 13, 2013
2bc1e6b
core::rt: Copy many of the old io extensions to the new io
brson May 14, 2013
d951da8
core::rt: Fix TCP test on mac
brson May 15, 2013
0d1331f
Merge remote-tracking branch 'brson/io' into incoming
brson May 15, 2013
018dfaf
core::rt: Unignore a fixed TCP test
brson May 15, 2013
03a8e59
Merge remote-tracking branch 'brson/io' into incoming
brson May 18, 2013
f5987b0
core::rt: implement `oneshot` and `stream`.
brson May 16, 2013
26becc3
core: Wire up oneshot pipes to newsched
brson May 17, 2013
df9e412
core: Wire up `stream` to newsched
brson May 18, 2013
633af4c
Whitespace
brson May 18, 2013
8daa5ec
xfail-fast run-pass/core-rt-smoke
brson May 18, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 57 additions & 8 deletions src/libcore/rt/mod.rs
Original file line number Diff line number Diff line change
@@ -8,12 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

/*! The Rust runtime, including the scheduler and I/O interface
/*! Rust runtime services, including the task scheduler and I/O interface

# XXX

* Unsafe uses of borrowed pointers should just use unsafe pointers
* Unwinding is not wired up correctly

*/

@@ -22,29 +21,76 @@

use libc::c_char;

/// The Scheduler and Task types, and thread-local access thereof
#[path = "sched/mod.rs"]
mod sched;
pub mod rtio;
pub mod uvll;
mod uvio;

/// Synchronous I/O
#[path = "io/mod.rs"]
pub mod io;

/// Thread-local implementations of language-critical runtime features like @
pub mod local_services;

/// The EventLoop and internal synchronous I/O interface, dynamically
/// overridable so that it's primary implementation on libuv can
/// live outside of core.
mod rtio;

/// libuv
#[path = "uv/mod.rs"]
mod uv;
#[path = "io/mod.rs"]
mod io;

/// The implementation of `rtio` for libuv
mod uvio;

/// C bindings to libuv
pub mod uvll;


// FIXME #5248: The import in `sched` doesn't resolve unless this is pub!
/// Bindings to pthread/windows thread-local storage
pub mod thread_local_storage;

/// A parallel work-stealing queue
mod work_queue;

/// Stack segments and their cacheing
mod stack;

/// CPU context swapping
mod context;

/// Bindings to system threading libraries
mod thread;

/// The runtime configuration, read from environment variables
pub mod env;
pub mod local_services;

/// The local, managed heap
mod local_heap;

/// Tools for testing the runtime
#[cfg(test)]
pub mod test;

/// Set up a default runtime configuration, given compiler-supplied arguments.
///
/// This is invoked by the `start` _language item_ (unstable::lang) to
/// run a Rust executable.
///
/// # Arguments
///
/// * `main` - A C-abi function that takes no arguments and returns `c_void`.
/// It is a wrapper around the user-defined `main` function, and will be run
/// in a task.
/// * `argc` & `argv` - The argument vector. On Unix this information is used
/// by os::args.
/// * `crate_map` - Runtime information about the executing crate, mostly for logging
///
/// # Return value
///
/// The return value is used as the process return code. 0 on success, 101 on error.
pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int {

use self::sched::{Scheduler, Task};
@@ -79,6 +125,8 @@ pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int {

/// Possible contexts in which Rust code may be executing.
/// Different runtime services are available depending on context.
/// Mostly used for determining if we're using the new scheduler
/// or the old scheduler.
#[deriving(Eq)]
pub enum RuntimeContext {
// Only the exchange heap is available
@@ -91,6 +139,7 @@ pub enum RuntimeContext {
OldTaskContext
}

/// Determine the current RuntimeContext
pub fn context() -> RuntimeContext {

use task::rt::rust_task;