Skip to content

Commit f94c153

Browse files
committed
---
yaml --- r: 69220 b: refs/heads/auto c: 921d991 h: refs/heads/master v: v3
1 parent e01d051 commit f94c153

File tree

7 files changed

+80
-11
lines changed

7 files changed

+80
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 2f7d86f9a86f0da23579eef50ba1275d36e6c0bc
17+
refs/heads/auto: 921d99108cd452f92569a0cafc8d11b36b38dfc0
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/compiletest/compiletest.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
242242
let mut tests = ~[];
243243
let dirs = os::list_dir_path(&config.src_base);
244244
for dirs.iter().advance |file| {
245-
let file = file.clone();
245+
let file = (*file).clone();
246246
debug!("inspecting file %s", file.to_str());
247-
if is_test(config, &file) {
248-
let t = do make_test(config, &file) {
247+
if is_test(config, file) {
248+
let t = do make_test(config, file) {
249249
match config.mode {
250-
mode_codegen => make_metrics_test_closure(config, &file),
251-
_ => make_test_closure(config, &file)
250+
mode_codegen => make_metrics_test_closure(config, file),
251+
_ => make_test_closure(config, file)
252252
}
253253
};
254254
tests.push(t)

branches/auto/src/librustc/metadata/filesearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn search<T>(filesearch: @FileSearch, pick: pick<T>) -> Option<T> {
9494
let r = os::list_dir_path(lib_search_path);
9595
for r.iter().advance |path| {
9696
debug!("testing %s", path.to_str());
97-
let maybe_picked = pick(path);
97+
let maybe_picked = pick(*path);
9898
if maybe_picked.is_some() {
9999
debug!("picked %s", path.to_str());
100100
rslt = maybe_picked;

branches/auto/src/librustpkg/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,9 @@ fn frob_source_file(workspace: &Path, pkgid: &PkgId) {
393393
}
394394
match maybe_p {
395395
Some(p) => {
396-
let w = io::file_writer(p, &[io::Append]);
396+
let w = io::file_writer(*p, &[io::Append]);
397397
match w {
398-
Err(s) => { let _ = cond.raise((p.clone(), fmt!("Bad path: %s", s))); }
398+
Err(s) => { let _ = cond.raise(((**p).clone(), fmt!("Bad path: %s", s))); }
399399
Ok(w) => w.write_line("")
400400
}
401401
}

branches/auto/src/libstd/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,8 +788,8 @@ pub fn list_dir(p: &Path) -> ~[~str] {
788788
*
789789
* This version prepends each entry with the directory.
790790
*/
791-
pub fn list_dir_path(p: &Path) -> ~[Path] {
792-
list_dir(p).map(|f| p.push(*f))
791+
pub fn list_dir_path(p: &Path) -> ~[~Path] {
792+
list_dir(p).map(|f| ~p.push(*f))
793793
}
794794

795795
/// Removes a directory at the specified path, after removing

branches/auto/src/libstd/rt/rtio.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub type IoFactoryObject = uvio::UvIoFactory;
2323
pub type RtioTcpStreamObject = uvio::UvTcpStream;
2424
pub type RtioTcpListenerObject = uvio::UvTcpListener;
2525
pub type RtioUdpSocketObject = uvio::UvUdpSocket;
26+
pub type RtioTimerObject = uvio::UvTimer;
2627

2728
pub trait EventLoop {
2829
fn run(&mut self);
@@ -46,6 +47,7 @@ pub trait IoFactory {
4647
fn tcp_connect(&mut self, addr: IpAddr) -> Result<~RtioTcpStreamObject, IoError>;
4748
fn tcp_bind(&mut self, addr: IpAddr) -> Result<~RtioTcpListenerObject, IoError>;
4849
fn udp_bind(&mut self, addr: IpAddr) -> Result<~RtioUdpSocketObject, IoError>;
50+
fn timer_init(&mut self) -> Result<~RtioTimerObject, IoError>;
4951
}
5052

5153
pub trait RtioTcpListener : RtioSocket {
@@ -84,3 +86,7 @@ pub trait RtioUdpSocket : RtioSocket {
8486
fn hear_broadcasts(&mut self);
8587
fn ignore_broadcasts(&mut self);
8688
}
89+
90+
pub trait RtioTimer {
91+
fn sleep(&self, msecs: u64);
92+
}

branches/auto/src/libstd/rt/uv/uvio.rs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,10 @@ impl IoFactory for UvIoFactory {
280280
}
281281
}
282282
}
283+
284+
fn timer_init(&mut self) -> Result<~RtioTimerObject, IoError> {
285+
Ok(~UvTimer(TimerWatcher::new(self.uv_loop())))
286+
}
283287
}
284288

285289
// FIXME #6090: Prefer newtype structs but Drop doesn't work
@@ -562,6 +566,48 @@ impl RtioUdpSocket for UvUdpSocket {
562566
fn ignore_broadcasts(&mut self) { fail!(); }
563567
}
564568

569+
pub struct UvTimer(timer::TimerWatcher);
570+
571+
impl UvTimer {
572+
fn new(w: timer::TimerWatcher) -> UvTimer {
573+
UvTimer(w)
574+
}
575+
}
576+
577+
impl Drop for UvTimer {
578+
fn drop(&self) {
579+
rtdebug!("closing UvTimer");
580+
let scheduler = Local::take::<Scheduler>();
581+
do scheduler.deschedule_running_task_and_then |_, task| {
582+
let task_cell = Cell::new(task);
583+
do self.close {
584+
let scheduler = Local::take::<Scheduler>();
585+
scheduler.resume_task_immediately(task_cell.take());
586+
}
587+
}
588+
}
589+
}
590+
591+
impl RtioTimer for UvTimer {
592+
fn sleep(&self, msecs: u64) {
593+
let scheduler = Local::take::<Scheduler>();
594+
assert!(scheduler.in_task_context());
595+
do scheduler.deschedule_running_task_and_then |sched, task| {
596+
rtdebug!("sleep: entered scheduler context");
597+
assert!(!sched.in_task_context());
598+
let task_cell = Cell::new(task);
599+
let mut watcher = **self;
600+
do watcher.start(msecs, 0) |_, status| {
601+
assert!(status.is_none());
602+
let scheduler = Local::take::<Scheduler>();
603+
scheduler.resume_task_immediately(task_cell.take());
604+
}
605+
}
606+
let mut w = **self;
607+
w.stop();
608+
}
609+
}
610+
565611
#[test]
566612
fn test_simple_io_no_connect() {
567613
do run_in_newsched_task {
@@ -832,3 +878,20 @@ fn test_udp_many_read() {
832878
}
833879
}
834880
}
881+
882+
fn test_timer_sleep_simple_impl() {
883+
unsafe {
884+
let io = Local::unsafe_borrow::<IoFactoryObject>();
885+
let timer = (*io).timer_init();
886+
match timer {
887+
Ok(t) => t.sleep(1),
888+
Err(_) => assert!(false)
889+
}
890+
}
891+
}
892+
#[test]
893+
fn test_timer_sleep_simple() {
894+
do run_in_newsched_task {
895+
test_timer_sleep_simple_impl();
896+
}
897+
}

0 commit comments

Comments
 (0)