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

Yet more newsched fixes #8299

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 0 additions & 10 deletions src/libstd/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ pub fn log_type<T>(level: u32, object: &T) {
fn newsched_log_str(msg: ~str) {
use rt::task::Task;
use rt::local::Local;
use str::StrSlice;
use container::Container;

// Truncate the string
let buf_bytes = 256;
let msg = if msg.len() > buf_bytes {
msg.slice(0, buf_bytes) + "[...]"
} else {
msg
};

unsafe {
match Local::try_unsafe_borrow::<Task>() {
Expand Down
21 changes: 17 additions & 4 deletions src/libstd/rt/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use either::*;
use libc;
use str::StrSlice;

pub trait Logger {
fn log(&mut self, msg: Either<~str, &'static str>);
Expand All @@ -35,10 +36,22 @@ impl Logger for StdErrLogger {
s
}
};
let dbg = ::libc::STDERR_FILENO as ::io::fd_t;
dbg.write_str(s);
dbg.write_str("\n");
dbg.flush();

// Truncate the string
let buf_bytes = 256;
if s.len() > buf_bytes {
let s = s.slice(0, buf_bytes) + "[...]";
print(s);
} else {
print(s)
};

fn print(s: &str) {
let dbg = ::libc::STDERR_FILENO as ::io::fd_t;
dbg.write_str(s);
dbg.write_str("\n");
dbg.flush();
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/libstd/rt/sched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ impl Scheduler {
let mut this = self;
match this.message_queue.pop() {
Some(PinnedTask(task)) => {
let mut task = task;
this.event_loop.callback(Scheduler::run_sched_once);
let mut task = task;
task.give_home(Sched(this.make_handle()));
this.resume_task_immediately(task);
return None;
Expand All @@ -351,10 +351,12 @@ impl Scheduler {
return this.sched_schedule_task(task);
}
Some(Wake) => {
this.event_loop.callback(Scheduler::run_sched_once);
this.sleepy = false;
return Some(this);
}
Some(Shutdown) => {
this.event_loop.callback(Scheduler::run_sched_once);
if this.sleepy {
// There may be an outstanding handle on the
// sleeper list. Pop them all to make sure that's
Expand Down