Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e7c2160f
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e7c2160f
编写于
3月 17, 2017
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix mutex's docs inconsistency
上级
cf69238b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
7 addition
and
7 deletion
+7
-7
src/libstd/sync/mutex.rs
src/libstd/sync/mutex.rs
+7
-7
未找到文件。
src/libstd/sync/mutex.rs
浏览文件 @
e7c2160f
...
...
@@ -30,7 +30,7 @@
///
/// The mutexes in this module implement a strategy called "poisoning" where a
/// mutex is considered poisoned whenever a thread panics while holding the
///
lock
. Once a mutex is poisoned, all other threads are unable to access the
///
mutex
. Once a mutex is poisoned, all other threads are unable to access the
/// data by default as it is likely tainted (some invariant is not being
/// upheld).
///
...
...
@@ -115,7 +115,7 @@ pub struct Mutex<T: ?Sized> {
// Note that this mutex is in a *box*, not inlined into the struct itself.
// Once a native mutex has been used once, its address can never change (it
// can't be moved). This mutex type can be safely moved at any time, so to
// ensure that the native mutex is used correctly we box the inner
lock
to
// ensure that the native mutex is used correctly we box the inner
mutex
to
// give it a constant address.
inner
:
Box
<
sys
::
Mutex
>
,
poison
:
poison
::
Flag
,
...
...
@@ -183,7 +183,7 @@ impl<T: ?Sized> Mutex<T> {
/// Acquires a mutex, blocking the current thread until it is able to do so.
///
/// This function will block the local thread until it is available to acquire
/// the mutex. Upon returning, the thread is the only thread with the
mutex
/// the mutex. Upon returning, the thread is the only thread with the
lock
/// held. An RAII guard is returned to allow scoped unlock of the lock. When
/// the guard goes out of scope, the mutex will be unlocked.
///
...
...
@@ -267,9 +267,9 @@ pub fn try_lock(&self) -> TryLockResult<MutexGuard<T>> {
}
}
/// Determines whether the
lock
is poisoned.
/// Determines whether the
mutex
is poisoned.
///
/// If another thread is active, the
lock
can still become poisoned at any
/// If another thread is active, the
mutex
can still become poisoned at any
/// time. You should not trust a `false` value for program correctness
/// without additional synchronization.
///
...
...
@@ -312,7 +312,7 @@ pub fn is_poisoned(&self) -> bool {
#[stable(feature
=
"mutex_into_inner"
,
since
=
"1.6.0"
)]
pub
fn
into_inner
(
self
)
->
LockResult
<
T
>
where
T
:
Sized
{
// We know statically that there are no outstanding references to
// `self` so there's no need to lock the inner
lock
.
// `self` so there's no need to lock the inner
mutex
.
//
// To get the inner value, we'd like to call `data.into_inner()`,
// but because `Mutex` impl-s `Drop`, we can't move out of it, so
...
...
@@ -353,7 +353,7 @@ pub fn into_inner(self) -> LockResult<T> where T: Sized {
#[stable(feature
=
"mutex_get_mut"
,
since
=
"1.6.0"
)]
pub
fn
get_mut
(
&
mut
self
)
->
LockResult
<&
mut
T
>
{
// We know statically that there are no other references to `self`, so
// there's no need to lock the inner
lock
.
// there's no need to lock the inner
mutex
.
let
data
=
unsafe
{
&
mut
*
self
.data
.get
()
};
poison
::
map_result
(
self
.poison
.borrow
(),
|
_
|
data
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录