Skip to content

Commit 9b7d356

Browse files
committed
---
yaml --- r: 97190 b: refs/heads/dist-snap c: 1763f36 h: refs/heads/master v: v3
1 parent 442dbb0 commit 9b7d356

39 files changed

+528
-1003
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 1b2cebc2c1f4d6e4bad36f4fa682f3d4e70cfb70
9+
refs/heads/dist-snap: 1763f36c9d47550838793e129f2297ecfc8bebd1
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ syn keyword rustTrait Default
7878
syn keyword rustTrait Hash
7979
syn keyword rustTrait FromStr
8080
syn keyword rustTrait FromIterator Extendable
81-
syn keyword rustTrait Iterator DoubleEndedIterator RandomAccessIterator CloneableIterator
81+
syn keyword rustTrait Iterator DoubleEndedIterator RandomAccessIterator ClonableIterator
8282
syn keyword rustTrait OrdIterator MutableDoubleEndedIterator ExactSize
8383
syn keyword rustTrait Times
8484

branches/dist-snap/src/libextra/enum_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! This module defines a container which uses an efficient bit mask
1414
//! representation to hold C-like enum variants.
1515
16-
#[deriving(Clone, Eq, IterBytes, ToStr, Encodable, Decodable)]
16+
#[deriving(Clone, Eq, IterBytes, ToStr)]
1717
/// A specialized Set implementation to use enum types.
1818
pub struct EnumSet<E> {
1919
// We must maintain the invariant that no bits are set

branches/dist-snap/src/libgreen/lib.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ impl SchedPool {
214214
pool.handles.push(sched.make_handle());
215215
let sched = sched;
216216
pool.threads.push(do Thread::start {
217-
sched.bootstrap();
217+
let mut sched = sched;
218+
let task = do GreenTask::new(&mut sched.stack_pool, None) {
219+
rtdebug!("boostraping a non-primary scheduler");
220+
};
221+
sched.bootstrap(task);
218222
});
219223
}
220224

@@ -266,7 +270,13 @@ impl SchedPool {
266270
let ret = sched.make_handle();
267271
self.handles.push(sched.make_handle());
268272
let sched = sched;
269-
self.threads.push(do Thread::start { sched.bootstrap() });
273+
self.threads.push(do Thread::start {
274+
let mut sched = sched;
275+
let task = do GreenTask::new(&mut sched.stack_pool, None) {
276+
rtdebug!("boostraping a non-primary scheduler");
277+
};
278+
sched.bootstrap(task);
279+
});
270280

271281
return ret;
272282
}

branches/dist-snap/src/libgreen/sched.rs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl Scheduler {
171171

172172
// Take a main task to run, and a scheduler to run it in. Create a
173173
// scheduler task and bootstrap into it.
174-
pub fn bootstrap(mut ~self) {
174+
pub fn bootstrap(mut ~self, task: ~GreenTask) {
175175

176176
// Build an Idle callback.
177177
let cb = ~SchedRunner as ~Callback;
@@ -187,11 +187,18 @@ impl Scheduler {
187187
self.idle_callback.get_mut_ref().resume();
188188

189189
// Now, as far as all the scheduler state is concerned, we are inside
190-
// the "scheduler" context. The scheduler immediately hands over control
191-
// to the event loop, and this will only exit once the event loop no
192-
// longer has any references (handles or I/O objects).
193-
rtdebug!("starting scheduler {}", self.sched_id());
194-
let mut sched_task = self.run(sched_task);
190+
// the "scheduler" context. So we can act like the scheduler and resume
191+
// the provided task. Let it think that the currently running task is
192+
// actually the sched_task so it knows where to squirrel it away.
193+
let mut sched_task = self.resume_task_immediately(sched_task, task);
194+
195+
// Now we are back in the scheduler context, having
196+
// successfully run the input task. Start by running the
197+
// scheduler. Grab it out of TLS - performing the scheduler
198+
// action will have given it away.
199+
let sched = sched_task.sched.take_unwrap();
200+
rtdebug!("starting scheduler {}", sched.sched_id());
201+
let mut sched_task = sched.run(sched_task);
195202

196203
// Close the idle callback.
197204
let mut sched = sched_task.sched.take_unwrap();
@@ -541,10 +548,7 @@ impl Scheduler {
541548
// We push the task onto our local queue clone.
542549
assert!(!task.is_sched());
543550
self.work_queue.push(task);
544-
match self.idle_callback {
545-
Some(ref mut idle) => idle.resume(),
546-
None => {} // allow enqueuing before the scheduler starts
547-
}
551+
self.idle_callback.get_mut_ref().resume();
548552

549553
// We've made work available. Notify a
550554
// sleeping scheduler.
@@ -1172,21 +1176,25 @@ mod test {
11721176
let mut sh = special_handle;
11731177
sh.send(Shutdown);
11741178
};
1175-
normal_sched.enqueue_task(normal_task);
1179+
11761180

11771181
let special_task = do GreenTask::new(&mut special_sched.stack_pool,
11781182
None) {
11791183
run(task1);
11801184
run(task3);
11811185
chan.send(());
11821186
};
1183-
special_sched.enqueue_task(special_task);
1187+
11841188

11851189
let normal_sched = normal_sched;
1186-
let normal_thread = do Thread::start { normal_sched.bootstrap() };
1190+
let normal_thread = do Thread::start {
1191+
normal_sched.bootstrap(normal_task);
1192+
};
11871193

11881194
let special_sched = special_sched;
1189-
let special_thread = do Thread::start { special_sched.bootstrap() };
1195+
let special_thread = do Thread::start {
1196+
special_sched.bootstrap(special_task);
1197+
};
11901198

11911199
normal_thread.join();
11921200
special_thread.join();

branches/dist-snap/src/libnative/io/file.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 {
3737
let mut ret;
3838
loop {
3939
ret = f(data, amt);
40-
if cfg!(not(windows)) { break } // windows has no eintr
40+
if cfg!(windows) { break } // windows has no eintr
4141
// if we get an eintr, then try again
4242
if ret != -1 || os::errno() as int != eintr { break }
4343
}
@@ -73,7 +73,10 @@ impl FileDesc {
7373
FileDesc { fd: fd, close_on_drop: close_on_drop }
7474
}
7575

76-
fn inner_read(&mut self, buf: &mut [u8]) -> Result<uint, IoError> {
76+
// FIXME(#10465) these functions should not be public, but anything in
77+
// native::io wanting to use them is forced to have all the
78+
// rtio traits in scope
79+
pub fn inner_read(&mut self, buf: &mut [u8]) -> Result<uint, IoError> {
7780
#[cfg(windows)] type rlen = libc::c_uint;
7881
#[cfg(not(windows))] type rlen = libc::size_t;
7982
let ret = keep_going(buf, |buf, len| {
@@ -899,7 +902,7 @@ pub fn utime(p: &CString, atime: u64, mtime: u64) -> IoResult<()> {
899902

900903
#[cfg(test)]
901904
mod tests {
902-
use super::{CFile, FileDesc};
905+
use super::{CFile, FileDesc, CloseFd};
903906
use std::io;
904907
use std::libc;
905908
use std::os;

branches/dist-snap/src/libnative/io/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn unimpl() -> IoError {
5555
}
5656
}
5757

58-
fn last_error() -> IoError {
58+
fn translate_error(errno: i32, detail: bool) -> IoError {
5959
#[cfg(windows)]
6060
fn get_err(errno: i32) -> (io::IoErrorKind, &'static str) {
6161
match errno {
@@ -79,14 +79,16 @@ fn last_error() -> IoError {
7979
}
8080
}
8181

82-
let (kind, desc) = get_err(os::errno() as i32);
82+
let (kind, desc) = get_err(errno);
8383
IoError {
8484
kind: kind,
8585
desc: desc,
86-
detail: Some(os::last_os_error())
86+
detail: if detail {Some(os::last_os_error())} else {None},
8787
}
8888
}
8989

90+
fn last_error() -> IoError { translate_error(os::errno() as i32, true) }
91+
9092
// unix has nonzero values as errors
9193
fn mkerr_libc(ret: libc::c_int) -> IoResult<()> {
9294
if ret != 0 {
@@ -106,6 +108,17 @@ fn mkerr_winbool(ret: libc::c_int) -> IoResult<()> {
106108
}
107109
}
108110

111+
#[cfg(unix)]
112+
fn retry(f: || -> libc::c_int) -> IoResult<libc::c_int> {
113+
loop {
114+
match f() {
115+
-1 if os::errno() as int == libc::EINTR as int => {}
116+
-1 => return Err(last_error()),
117+
n => return Ok(n),
118+
}
119+
}
120+
}
121+
109122
/// Implementation of rt::rtio's IoFactory trait to generate handles to the
110123
/// native I/O functionality.
111124
pub struct IoFactory;

0 commit comments

Comments
 (0)