mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
fe3ef7d998
This is an easy step toward adopting 2018 edition eventually, and will make any future CL that sets `edition = "2018"` this much smaller. The module system changes in Rust 2018 are described here: https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html Generated by running: cargo fix --edition --all in each workspace, followed by bin/fmt. TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: I000ab5e69d69aa222c272fae899464bbaf65f6d8 Reviewed-on: https://chromium-review.googlesource.com/1513054 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
28 lines
1.4 KiB
Rust
28 lines
1.4 KiB
Rust
// Copyright 2018 The Chromium OS Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
//! Sync primitive types whose methods panic rather than returning error in case of poison.
|
|
//!
|
|
//! The Mutex/Condvar type in this crates wraps the standard library versions and mirrors the same
|
|
//! methods, except that they panic where the standard library would return an Error. This API
|
|
//! codifies our error handling strategy around poisoned mutexes in crosvm.
|
|
//!
|
|
//! - Crosvm releases are built with panic=abort so poisoning never occurs. A panic while a mutex is
|
|
//! held (or ever) takes down the entire process. Thus we would like for code not to have to
|
|
//! consider the possibility of poison.
|
|
//!
|
|
//! - We could ask developers to always write `.lock().unwrap()` on a standard library mutex.
|
|
//! However, we would like to stigmatize the use of unwrap. It is confusing to permit unwrap but
|
|
//! only on mutex lock results. During code review it may not always be obvious whether a
|
|
//! particular unwrap is unwrapping a mutex lock result or a different error that should be
|
|
//! handled in a more principled way.
|
|
//!
|
|
//! Developers should feel free to use types defined in this crate anywhere in crosvm that they
|
|
//! would otherwise be using the corresponding types in std::sync.
|
|
|
|
mod condvar;
|
|
mod mutex;
|
|
|
|
pub use crate::condvar::Condvar;
|
|
pub use crate::mutex::{Mutex, WouldBlock};
|