rust/src/libstd/io
Alex Crichton 76e5ed655c std: Return Result from RWLock/Mutex methods
All of the current std::sync primitives have poisoning enable which means that
when a task fails inside of a write-access lock then all future attempts to
acquire the lock will fail. This strategy ensures that stale data whose
invariants are possibly not upheld are never viewed by other tasks to help
propagate unexpected panics (bugs in a program) among tasks.

Currently there is no way to test whether a mutex or rwlock is poisoned. One
method would be to duplicate all the methods with a sister foo_catch function,
for example. This pattern is, however, against our [error guidelines][errors].
As a result, this commit exposes the fact that a task has failed internally
through the return value of a `Result`.

[errors]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants

All methods now return a `LockResult<T>` or a `TryLockResult<T>` which
communicates whether the lock was poisoned or not. In a `LockResult`, both the
`Ok` and `Err` variants contains the `MutexGuard<T>` that is being returned in
order to allow access to the data if poisoning is not desired. This also means
that the lock is *always* held upon returning from `.lock()`.

A new type, `PoisonError`, was added with one method `into_guard` which can
consume the assertion that a lock is poisoned to gain access to the underlying
data.

This is a breaking change because the signatures of these methods have changed,
often incompatible ways. One major difference is that the `wait` methods on a
condition variable now consume the guard and return it in as a `LockResult` to
indicate whether the lock was poisoned while waiting. Most code can be updated
by calling `.unwrap()` on the return value of `.lock()`.

[breaking-change]
2014-12-29 09:18:09 -08:00
..
net Fix fallout 2014-12-27 09:55:25 +13:00
buffered.rs Implement RaceBox for StdinReader 2014-12-26 17:26:33 +01:00
comm_adapters.rs Stabilize clone 2014-12-20 00:37:44 -08:00
extensions.rs librustc: Always parse macro!()/macro![] as expressions if not 2014-12-18 12:09:07 -05:00
fs.rs Fix fallout of removing import_shadowing in tests. 2014-12-20 07:49:37 +02:00
mem.rs Fix fallout 2014-12-27 09:55:25 +13:00
mod.rs Fallout of changing format_args!(f, args) to f(format_args!(args)). 2014-12-27 23:57:43 +02:00
pipe.rs Mostly rote conversion of proc() to move|| (and occasionally Thunk::new) 2014-12-14 04:21:56 -05:00
process.rs Fix fallout 2014-12-27 09:55:25 +13:00
result.rs Utilize fewer reexports 2014-12-05 18:13:04 -05:00
stdio.rs std: Return Result from RWLock/Mutex methods 2014-12-29 09:18:09 -08:00
tempfile.rs Replaced wrapper functions with no_run and as_str().unwrap() with display() 2014-12-17 07:21:29 +01:00
test.rs
timer.rs Fix fallout of removing import_shadowing in tests. 2014-12-20 07:49:37 +02:00
util.rs libstd: use #[deriving(Copy)] 2014-12-19 10:51:00 -05:00