Skip to content

Commit da87b6a

Browse files
committed
---
yaml --- r: 145083 b: refs/heads/try2 c: 0dbd509 h: refs/heads/master i: 145081: 569ceac 145079: dbaaab4 v: v3
1 parent 1d3833e commit da87b6a

File tree

5 files changed

+85
-11
lines changed

5 files changed

+85
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: a18038f3b2ee338de05ef4489d6ac7067c9198fd
8+
refs/heads/try2: 0dbd509e0f90bc13f7b49c24e48a281928b2ee9c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libstd/comm.rs

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,6 @@ pub fn stream<T: Send>() -> (Port<T>, Chan<T>) {
6666
(Port { x: p }, Chan { x: c })
6767
}
6868

69-
pub struct SharedChan<T> { x: rtcomm::SharedChan<T> }
70-
71-
impl<T: Send> SharedChan<T> {
72-
pub fn new(c: Chan<T>) -> SharedChan<T> {
73-
let Chan { x: c } = c;
74-
SharedChan { x: rtcomm::SharedChan::new(c) }
75-
}
76-
}
77-
7869
impl<T: Send> ChanOne<T> {
7970
pub fn send(self, val: T) {
8071
let ChanOne { x: c } = self;
@@ -161,6 +152,16 @@ impl<T: Send> Peekable<T> for Port<T> {
161152
}
162153
}
163154

155+
156+
pub struct SharedChan<T> { x: rtcomm::SharedChan<T> }
157+
158+
impl<T: Send> SharedChan<T> {
159+
pub fn new(c: Chan<T>) -> SharedChan<T> {
160+
let Chan { x: c } = c;
161+
SharedChan { x: rtcomm::SharedChan::new(c) }
162+
}
163+
}
164+
164165
impl<T: Send> GenericChan<T> for SharedChan<T> {
165166
fn send(&self, val: T) {
166167
let &SharedChan { x: ref c } = self;
@@ -193,3 +194,31 @@ impl<T> Clone for SharedChan<T> {
193194
SharedChan { x: c.clone() }
194195
}
195196
}
197+
198+
pub struct SharedPort<T> { x: rtcomm::SharedPort<T> }
199+
200+
impl<T: Send> SharedPort<T> {
201+
pub fn new(p: Port<T>) -> SharedPort<T> {
202+
let Port { x: p } = p;
203+
SharedPort { x: rtcomm::SharedPort::new(p) }
204+
}
205+
}
206+
207+
impl<T: Send> GenericPort<T> for SharedPort<T> {
208+
fn recv(&self) -> T {
209+
let &SharedPort { x: ref p } = self;
210+
p.recv()
211+
}
212+
213+
fn try_recv(&self) -> Option<T> {
214+
let &SharedPort { x: ref p } = self;
215+
p.try_recv()
216+
}
217+
}
218+
219+
impl<T> Clone for SharedPort<T> {
220+
fn clone(&self) -> SharedPort<T> {
221+
let &SharedPort { x: ref p } = self;
222+
SharedPort { x: p.clone() }
223+
}
224+
}

branches/try2/src/libstd/rt/io/timer.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ use rt::local::Local;
1717

1818
pub struct Timer(~RtioTimerObject);
1919

20+
/// Sleep the current task for `msecs` milliseconds.
21+
pub fn sleep(msecs: u64) {
22+
let mut timer = Timer::new().expect("timer::sleep: could not create a Timer");
23+
24+
timer.sleep(msecs)
25+
}
26+
2027
impl Timer {
2128

2229
pub fn new() -> Option<Timer> {
@@ -52,4 +59,11 @@ mod test {
5259
do timer.map_move |mut t| { t.sleep(1) };
5360
}
5461
}
62+
63+
#[test]
64+
fn test_io_timer_sleep_standalone() {
65+
do run_in_mt_newsched_task {
66+
sleep(1)
67+
}
68+
}
5569
}

branches/try2/src/libsyntax/ext/expand.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,26 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
7676
// mark before:
7777
let marked_before = mark_tts(*tts,fm);
7878
let marked_ctxt = new_mark(fm, ctxt);
79+
80+
// The span that we pass to the expanders we want to
81+
// be the root of the call stack. That's the most
82+
// relevant span and it's the actual invocation of
83+
// the macro.
84+
let mut relevant_info = cx.backtrace();
85+
let mut einfo = relevant_info.unwrap();
86+
loop {
87+
match relevant_info {
88+
None => { break }
89+
Some(e) => {
90+
einfo = e;
91+
relevant_info = einfo.call_site.expn_info;
92+
}
93+
}
94+
}
95+
7996
let expanded =
80-
match expandfun(cx, mac.span, marked_before, marked_ctxt) {
97+
match expandfun(cx, einfo.call_site,
98+
marked_before, marked_ctxt) {
8199
MRExpr(e) => e,
82100
MRAny(expr_maker,_,_) => expr_maker(),
83101
_ => {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
debug!("%s %s", 3); //~ ERROR: not enough arguments
13+
}

0 commit comments

Comments
 (0)