Skip to content

Commit 4bf1c4d

Browse files
committed
---
yaml --- r: 67517 b: refs/heads/master c: fe28ac6 h: refs/heads/master i: 67515: 3584201 v: v3
1 parent a09d105 commit 4bf1c4d

25 files changed

+190
-277
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: e995d9935b5bccb484db85b75a344258e74f21a5
2+
refs/heads/master: fe28ac6891ae2619094e88d9b7859772e685a27f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/libextra/arc.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,16 +576,12 @@ mod tests {
576576
let (p, c) = comm::stream();
577577
578578
do task::spawn() || {
579-
let p = comm::PortSet::new();
580-
c.send(p.chan());
581-
582579
let arc_v : Arc<~[int]> = p.recv();
583580
584581
let v = (*arc_v.get()).clone();
585582
assert_eq!(v[3], 4);
586583
};
587584
588-
let c = p.recv();
589585
c.send(arc_v.clone());
590586
591587
assert_eq!(arc_v.get()[2], 3);

trunk/src/libstd/comm.rs

Lines changed: 2 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@ Message passing
1414

1515
#[allow(missing_doc)];
1616

17-
use cast::{transmute, transmute_mut};
18-
use container::Container;
17+
use cast::transmute;
1918
use either::{Either, Left, Right};
2019
use kinds::Send;
21-
use option::{Option, Some, None};
22-
use uint;
23-
use vec::OwnedVector;
24-
use util::replace;
20+
use option::{Option, Some};
2521
use unstable::sync::Exclusive;
2622
use rtcomm = rt::comm;
2723
use rt;
@@ -143,81 +139,6 @@ impl<T: Send> Selectable for Port<T> {
143139
}
144140
}
145141

146-
/// Treat many ports as one.
147-
#[unsafe_mut_field(ports)]
148-
pub struct PortSet<T> {
149-
ports: ~[pipesy::Port<T>],
150-
}
151-
152-
impl<T: Send> PortSet<T> {
153-
pub fn new() -> PortSet<T> {
154-
PortSet {
155-
ports: ~[]
156-
}
157-
}
158-
159-
pub fn add(&self, port: Port<T>) {
160-
let Port { inner } = port;
161-
let port = match inner {
162-
Left(p) => p,
163-
Right(_) => fail!("PortSet not implemented")
164-
};
165-
unsafe {
166-
let self_ports = transmute_mut(&self.ports);
167-
self_ports.push(port)
168-
}
169-
}
170-
171-
pub fn chan(&self) -> Chan<T> {
172-
let (po, ch) = stream();
173-
self.add(po);
174-
ch
175-
}
176-
}
177-
178-
impl<T:Send> GenericPort<T> for PortSet<T> {
179-
fn try_recv(&self) -> Option<T> {
180-
unsafe {
181-
let self_ports = transmute_mut(&self.ports);
182-
let mut result = None;
183-
// we have to swap the ports array so we aren't borrowing
184-
// aliasable mutable memory.
185-
let mut ports = replace(self_ports, ~[]);
186-
while result.is_none() && ports.len() > 0 {
187-
let i = wait_many(ports);
188-
match ports[i].try_recv() {
189-
Some(m) => {
190-
result = Some(m);
191-
}
192-
None => {
193-
// Remove this port.
194-
let _ = ports.swap_remove(i);
195-
}
196-
}
197-
}
198-
*self_ports = ports;
199-
result
200-
}
201-
}
202-
fn recv(&self) -> T {
203-
self.try_recv().expect("port_set: endpoints closed")
204-
}
205-
}
206-
207-
impl<T: Send> Peekable<T> for PortSet<T> {
208-
fn peek(&self) -> bool {
209-
// It'd be nice to use self.port.each, but that version isn't
210-
// pure.
211-
for uint::range(0, self.ports.len()) |i| {
212-
let port: &pipesy::Port<T> = &self.ports[i];
213-
if port.peek() {
214-
return true;
215-
}
216-
}
217-
false
218-
}
219-
}
220-
221142
/// A channel that can be shared between many senders.
222143
pub struct SharedChan<T> {
223144
inner: Either<Exclusive<pipesy::Chan<T>>, rtcomm::SharedChan<T>>

trunk/src/libstd/nil.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Functions for the unit type.
1616

1717
#[cfg(not(test))]
1818
use prelude::*;
19+
#[cfg(not(test))]
20+
use num::Zero;
21+
22+
1923

2024
#[cfg(not(test))]
2125
impl Eq for () {
@@ -48,3 +52,10 @@ impl TotalEq for () {
4852
#[inline]
4953
fn equals(&self, _other: &()) -> bool { true }
5054
}
55+
56+
#[cfg(not(test))]
57+
impl Zero for () {
58+
fn zero() -> () { () }
59+
fn is_zero(&self) -> bool { true }
60+
}
61+

trunk/src/libstd/rt/kill.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ pub struct Death {
8484
on_exit: Option<~fn(bool)>,
8585
// nesting level counter for task::unkillable calls (0 == killable).
8686
unkillable: int,
87-
// nesting level counter for task::atomically calls (0 == can yield).
87+
// nesting level counter for unstable::atomically calls (0 == can yield).
8888
wont_sleep: int,
8989
// A "spare" handle to the kill flag inside the kill handle. Used during
9090
// blocking/waking as an optimization to avoid two xadds on the refcount.

trunk/src/libstd/rt/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,14 @@ fn run_(main: ~fn(), use_main_sched: bool) -> int {
316316
// Just put an unpinned task onto one of the default schedulers.
317317
let mut main_task = ~Task::new_root(&mut scheds[0].stack_pool, main);
318318
main_task.death.on_exit = Some(on_exit);
319+
main_task.name = Some(~"main");
319320
scheds[0].enqueue_task(main_task);
320321
}
321322
Some(ref mut main_sched) => {
322323
let home = Sched(main_sched.make_handle());
323324
let mut main_task = ~Task::new_root_homed(&mut scheds[0].stack_pool, home, main);
324325
main_task.death.on_exit = Some(on_exit);
326+
main_task.name = Some(~"main");
325327
main_sched.enqueue_task(main_task);
326328
}
327329
};

trunk/src/libstd/rt/task.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ pub struct Task {
4040
taskgroup: Option<Taskgroup>,
4141
death: Death,
4242
destroyed: bool,
43-
coroutine: Option<~Coroutine>
43+
coroutine: Option<~Coroutine>,
44+
// FIXME(#6874/#7599) use StringRef to save on allocations
45+
name: Option<~str>,
4446
}
4547

4648
pub struct Coroutine {
@@ -90,7 +92,8 @@ impl Task {
9092
taskgroup: None,
9193
death: Death::new(),
9294
destroyed: false,
93-
coroutine: Some(~Coroutine::new(stack_pool, start))
95+
coroutine: Some(~Coroutine::new(stack_pool, start)),
96+
name: None,
9497
}
9598
}
9699

@@ -109,7 +112,8 @@ impl Task {
109112
// FIXME(#7544) make watching optional
110113
death: self.death.new_child(),
111114
destroyed: false,
112-
coroutine: Some(~Coroutine::new(stack_pool, start))
115+
coroutine: Some(~Coroutine::new(stack_pool, start)),
116+
name: None,
113117
}
114118
}
115119

trunk/src/libstd/sys.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,13 @@ impl FailWithCause for &'static str {
137137

138138
// FIXME #4427: Temporary until rt::rt_fail_ goes away
139139
pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
140-
use cell::Cell;
141140
use either::Left;
141+
use option::{Some, None};
142142
use rt::{context, OldTaskContext, TaskContext};
143143
use rt::task::Task;
144144
use rt::local::Local;
145145
use rt::logging::Logger;
146+
use str::Str;
146147

147148
let context = context();
148149
match context {
@@ -159,20 +160,26 @@ pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
159160
let msg = str::raw::from_c_str(msg);
160161
let file = str::raw::from_c_str(file);
161162

162-
let outmsg = fmt!("task failed at '%s', %s:%i",
163-
msg, file, line as int);
164-
165163
// XXX: Logging doesn't work correctly in non-task context because it
166164
// invokes the local heap
167165
if context == TaskContext {
168166
// XXX: Logging doesn't work here - the check to call the log
169167
// function never passes - so calling the log function directly.
170-
let outmsg = Cell::new(outmsg);
171168
do Local::borrow::<Task, ()> |task| {
172-
task.logger.log(Left(outmsg.take()));
169+
let msg = match task.name {
170+
Some(ref name) =>
171+
fmt!("task '%s' failed at '%s', %s:%i",
172+
name.as_slice(), msg, file, line as int),
173+
None =>
174+
fmt!("task <unnamed> failed at '%s', %s:%i",
175+
msg, file, line as int)
176+
};
177+
178+
task.logger.log(Left(msg));
173179
}
174180
} else {
175-
rterrln!("%s", outmsg);
181+
rterrln!("failed in non-task context at '%s', %s:%i",
182+
msg, file, line as int);
176183
}
177184

178185
gc::cleanup_stack_for_failure();

0 commit comments

Comments
 (0)