Skip to content

Commit aec7216

Browse files
author
Keegan McAllister
committed
---
yaml --- r: 179551 b: refs/heads/snap-stage3 c: 7324c2c h: refs/heads/master i: 179549: e5b6ca6 179547: 311b28b 179543: 0c02fe0 179535: 8a5b646 179519: 2a4b73f v: v3
1 parent 398c233 commit aec7216

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 0ba9e1fa52627404a1e5b90f745f96a872a0c564
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 96c3a13680d521387007e2f6575483c24561ecb3
4+
refs/heads/snap-stage3: 7324c2cf4f09d44d1bde8c37716de9eca4aac565
55
refs/heads/try: ccf8fedf1cffcb8f6f3581d53d220039e192fe77
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libstd/sync/condvar.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use sys::time::SteadyTime;
1616
use sys_common::condvar as sys;
1717
use sys_common::mutex as sys_mutex;
1818
use time::Duration;
19-
use sync::{mutex, MutexGuard};
19+
use sync::{mutex, MutexGuard, PoisonError};
2020

2121
/// A Condition Variable
2222
///
@@ -228,7 +228,7 @@ impl StaticCondvar {
228228
mutex::guard_poison(&guard).get()
229229
};
230230
if poisoned {
231-
Err(poison::new_poison_error(guard))
231+
Err(PoisonError::new(guard))
232232
} else {
233233
Ok(guard)
234234
}
@@ -249,7 +249,7 @@ impl StaticCondvar {
249249
(mutex::guard_poison(&guard).get(), success)
250250
};
251251
if poisoned {
252-
Err(poison::new_poison_error((guard, success)))
252+
Err(PoisonError::new((guard, success)))
253253
} else {
254254
Ok((guard, success))
255255
}
@@ -276,23 +276,23 @@ impl StaticCondvar {
276276
while !f(guard_result
277277
.as_mut()
278278
.map(|g| &mut **g)
279-
.map_err(|e| poison::new_poison_error(&mut **e.get_mut()))) {
279+
.map_err(|e| PoisonError::new(&mut **e.get_mut()))) {
280280
let now = SteadyTime::now();
281281
let consumed = &now - &start;
282282
let guard = guard_result.unwrap_or_else(|e| e.into_inner());
283283
let (new_guard_result, no_timeout) = match self.wait_timeout(guard, dur - consumed) {
284284
Ok((new_guard, no_timeout)) => (Ok(new_guard), no_timeout),
285285
Err(err) => {
286286
let (new_guard, no_timeout) = err.into_inner();
287-
(Err(poison::new_poison_error(new_guard)), no_timeout)
287+
(Err(PoisonError::new(new_guard)), no_timeout)
288288
}
289289
};
290290
guard_result = new_guard_result;
291291
if !no_timeout {
292292
let result = f(guard_result
293293
.as_mut()
294294
.map(|g| &mut **g)
295-
.map_err(|e| poison::new_poison_error(&mut **e.get_mut())));
295+
.map_err(|e| PoisonError::new(&mut **e.get_mut())));
296296
return poison::map_result(guard_result, |g| (g, result));
297297
}
298298
}

branches/snap-stage3/src/libstd/sync/poison.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl Flag {
2323
pub fn borrow(&self) -> LockResult<Guard> {
2424
let ret = Guard { panicking: Thread::panicking() };
2525
if unsafe { *self.failed.get() } {
26-
Err(new_poison_error(ret))
26+
Err(PoisonError::new(ret))
2727
} else {
2828
Ok(ret)
2929
}
@@ -110,6 +110,12 @@ impl<T> Error for PoisonError<T> {
110110
}
111111

112112
impl<T> PoisonError<T> {
113+
/// Create a `PoisonError`.
114+
#[unstable(feature = "std_misc")]
115+
pub fn new(guard: T) -> PoisonError<T> {
116+
PoisonError { guard: guard }
117+
}
118+
113119
/// Consumes this error indicating that a lock is poisoned, returning the
114120
/// underlying guard to allow access regardless.
115121
#[unstable(feature = "std_misc")]
@@ -171,15 +177,11 @@ impl<T> Error for TryLockError<T> {
171177
}
172178
}
173179

174-
pub fn new_poison_error<T>(guard: T) -> PoisonError<T> {
175-
PoisonError { guard: guard }
176-
}
177-
178180
pub fn map_result<T, U, F>(result: LockResult<T>, f: F)
179181
-> LockResult<U>
180182
where F: FnOnce(T) -> U {
181183
match result {
182184
Ok(t) => Ok(f(t)),
183-
Err(PoisonError { guard }) => Err(new_poison_error(f(guard)))
185+
Err(PoisonError { guard }) => Err(PoisonError::new(f(guard)))
184186
}
185187
}

0 commit comments

Comments
 (0)