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
Show file tree
Hide file tree
Changes from all commits
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
681 changes: 436 additions & 245 deletions src/libcore/comm.rs

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/libcore/core.rc
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,11 @@ mod unicode;
#[path = "num/cmath.rs"]
mod cmath;
mod stackwalk;

// XXX: This shouldn't be pub, and it should be reexported under 'unstable'
// but name resolution doesn't work without it being pub.
#[path = "rt/mod.rs"]
mod rt;
pub mod rt;

// A curious inner-module that's not exported that contains the binding
// 'core' so that macro-expanded references to core::error and such
Expand Down
63 changes: 50 additions & 13 deletions src/libcore/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@

//! Logging

pub mod rustrt {
use libc;

pub extern {
unsafe fn rust_log_console_on();
unsafe fn rust_log_console_off();
unsafe fn rust_log_str(level: u32,
string: *libc::c_char,
size: libc::size_t);
}
}
use option::*;
use either::*;
use rt;
use rt::logging::{Logger, StdErrLogger};
use io;
use libc;
use repr;
use vec;
use cast;
use str;

/// Turns on logging to stdout globally
pub fn console_on() {
Expand Down Expand Up @@ -55,8 +54,46 @@ pub fn log_type<T>(level: u32, object: &T) {
let bytes = do io::with_bytes_writer |writer| {
repr::write_repr(writer, object);
};

match rt::context() {
rt::OldTaskContext => {
unsafe {
let len = bytes.len() as libc::size_t;
rustrt::rust_log_str(level, cast::transmute(vec::raw::to_ptr(bytes)), len);
}
}
_ => {
// XXX: Bad allocation
let msg = str::from_bytes(bytes);
newsched_log_str(msg);
}
}
}

fn newsched_log_str(msg: ~str) {
unsafe {
let len = bytes.len() as libc::size_t;
rustrt::rust_log_str(level, transmute(vec::raw::to_ptr(bytes)), len);
match rt::local_services::unsafe_try_borrow_local_services() {
Some(local) => {
// Use the available logger
(*local).logger.log(Left(msg));
}
None => {
// There is no logger anywhere, just write to stderr
let mut logger = StdErrLogger;
logger.log(Left(msg));
}
}
}
}

pub mod rustrt {
use libc;

pub extern {
unsafe fn rust_log_console_on();
unsafe fn rust_log_console_off();
unsafe fn rust_log_str(level: u32,
string: *libc::c_char,
size: libc::size_t);
}
}
16 changes: 15 additions & 1 deletion src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,24 @@ macro_rules! rtdebug (
($( $arg:expr),+) => ( $(let _ = $arg)*; )
)

macro_rules! rtassert (
( $arg:expr ) => ( {
if !$arg {
abort!("assertion failed: %s", stringify!($arg));
}
} )
)

macro_rules! abort(
($( $msg:expr),+) => ( {
rtdebug!($($msg),+);

unsafe { ::libc::abort(); }
do_abort();

// NB: This is in a fn to avoid putting the `unsafe` block in a macro,
// which causes spurious 'unnecessary unsafe block' warnings.
fn do_abort() -> ! {
unsafe { ::libc::abort(); }
}
} )
)
28 changes: 15 additions & 13 deletions src/libcore/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,25 @@ pub mod win32 {

/*
Accessing environment variables is not generally threadsafe.
This uses a per-runtime lock to serialize access.
FIXME #4726: It would probably be appropriate to make this a real global
Serialize access through a global lock.
*/
fn with_env_lock<T>(f: &fn() -> T) -> T {
use unstable::global::global_data_clone_create;
use unstable::sync::{Exclusive, exclusive};

struct SharedValue(());
type ValueMutex = Exclusive<SharedValue>;
fn key(_: ValueMutex) { }
use unstable::finally::Finally;

unsafe {
let lock: ValueMutex = global_data_clone_create(key, || {
~exclusive(SharedValue(()))
});
return do (|| {
rust_take_env_lock();
f()
}).finally {
rust_drop_env_lock();
};
}

lock.with_imm(|_| f() )
extern {
#[fast_ffi]
fn rust_take_env_lock();
#[fast_ffi]
fn rust_drop_env_lock();
}
}

Expand Down Expand Up @@ -749,7 +751,7 @@ pub fn list_dir(p: &Path) -> ~[~str] {
use os::win32::{
as_utf16_p
};
use unstable::exchange_alloc::{malloc_raw, free_raw};
use rt::global_heap::{malloc_raw, free_raw};
#[nolink]
extern {
unsafe fn rust_list_dir_wfd_size() -> libc::size_t;
Expand Down
Loading