Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
49697ae3
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,发现更多精彩内容 >>
提交
49697ae3
编写于
12月 06, 2019
作者:
R
Ralf Jung
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
get rid of __ in field names
上级
d0126e8e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
26 deletion
+24
-26
src/libstd/sync/mutex.rs
src/libstd/sync/mutex.rs
+10
-12
src/libstd/sync/rwlock.rs
src/libstd/sync/rwlock.rs
+14
-14
未找到文件。
src/libstd/sync/mutex.rs
浏览文件 @
49697ae3
...
...
@@ -143,10 +143,8 @@ unsafe impl<T: ?Sized + Send> Sync for Mutex<T> { }
#[must_use
=
"if unused the Mutex will immediately unlock"
]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
MutexGuard
<
'a
,
T
:
?
Sized
+
'a
>
{
// funny underscores due to how Deref/DerefMut currently work (they
// disregard field privacy).
__
lock
:
&
'a
Mutex
<
T
>
,
__
poison
:
poison
::
Guard
,
lock
:
&
'a
Mutex
<
T
>
,
poison
:
poison
::
Guard
,
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
...
...
@@ -417,8 +415,8 @@ impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> {
unsafe
fn
new
(
lock
:
&
'mutex
Mutex
<
T
>
)
->
LockResult
<
MutexGuard
<
'mutex
,
T
>>
{
poison
::
map_result
(
lock
.poison
.borrow
(),
|
guard
|
{
MutexGuard
{
__
lock
:
lock
,
__
poison
:
guard
,
lock
:
lock
,
poison
:
guard
,
}
})
}
...
...
@@ -429,14 +427,14 @@ impl<T: ?Sized> Deref for MutexGuard<'_, T> {
type
Target
=
T
;
fn
deref
(
&
self
)
->
&
T
{
unsafe
{
&*
self
.
__
lock.data
.get
()
}
unsafe
{
&*
self
.lock.data
.get
()
}
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
:
?
Sized
>
DerefMut
for
MutexGuard
<
'_
,
T
>
{
fn
deref_mut
(
&
mut
self
)
->
&
mut
T
{
unsafe
{
&
mut
*
self
.
__
lock.data
.get
()
}
unsafe
{
&
mut
*
self
.lock.data
.get
()
}
}
}
...
...
@@ -445,8 +443,8 @@ impl<T: ?Sized> Drop for MutexGuard<'_, T> {
#[inline]
fn
drop
(
&
mut
self
)
{
unsafe
{
self
.
__lock.poison
.done
(
&
self
.__
poison
);
self
.
__
lock.inner
.raw_unlock
();
self
.
lock.poison
.done
(
&
self
.
poison
);
self
.lock.inner
.raw_unlock
();
}
}
}
...
...
@@ -466,11 +464,11 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
pub
fn
guard_lock
<
'a
,
T
:
?
Sized
>
(
guard
:
&
MutexGuard
<
'a
,
T
>
)
->
&
'a
sys
::
Mutex
{
&
guard
.
__
lock.inner
&
guard
.lock.inner
}
pub
fn
guard_poison
<
'a
,
T
:
?
Sized
>
(
guard
:
&
MutexGuard
<
'a
,
T
>
)
->
&
'a
poison
::
Flag
{
&
guard
.
__
lock.poison
&
guard
.lock.poison
}
#[cfg(all(test,
not(target_os
=
"emscripten"
)))]
...
...
src/libstd/sync/rwlock.rs
浏览文件 @
49697ae3
...
...
@@ -87,7 +87,7 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
#[must_use
=
"if unused the RwLock will immediately unlock"
]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
RwLockReadGuard
<
'a
,
T
:
?
Sized
+
'a
>
{
__
lock
:
&
'a
RwLock
<
T
>
,
lock
:
&
'a
RwLock
<
T
>
,
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
...
...
@@ -108,8 +108,8 @@ unsafe impl<T: ?Sized + Sync> Sync for RwLockReadGuard<'_, T> {}
#[must_use
=
"if unused the RwLock will immediately unlock"
]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
struct
RwLockWriteGuard
<
'a
,
T
:
?
Sized
+
'a
>
{
__
lock
:
&
'a
RwLock
<
T
>
,
__
poison
:
poison
::
Guard
,
lock
:
&
'a
RwLock
<
T
>
,
poison
:
poison
::
Guard
,
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
...
...
@@ -465,7 +465,7 @@ unsafe fn new(lock: &'rwlock RwLock<T>)
->
LockResult
<
RwLockReadGuard
<
'rwlock
,
T
>>
{
poison
::
map_result
(
lock
.poison
.borrow
(),
|
_
|
{
RwLockReadGuard
{
__
lock
:
lock
,
lock
:
lock
,
}
})
}
...
...
@@ -476,8 +476,8 @@ unsafe fn new(lock: &'rwlock RwLock<T>)
->
LockResult
<
RwLockWriteGuard
<
'rwlock
,
T
>>
{
poison
::
map_result
(
lock
.poison
.borrow
(),
|
guard
|
{
RwLockWriteGuard
{
__
lock
:
lock
,
__
poison
:
guard
,
lock
:
lock
,
poison
:
guard
,
}
})
}
...
...
@@ -487,7 +487,7 @@ unsafe fn new(lock: &'rwlock RwLock<T>)
impl
<
T
:
fmt
::
Debug
>
fmt
::
Debug
for
RwLockReadGuard
<
'_
,
T
>
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
f
.debug_struct
(
"RwLockReadGuard"
)
.field
(
"lock"
,
&
self
.
__
lock
)
.field
(
"lock"
,
&
self
.lock
)
.finish
()
}
}
...
...
@@ -503,7 +503,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl
<
T
:
fmt
::
Debug
>
fmt
::
Debug
for
RwLockWriteGuard
<
'_
,
T
>
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
f
.debug_struct
(
"RwLockWriteGuard"
)
.field
(
"lock"
,
&
self
.
__
lock
)
.field
(
"lock"
,
&
self
.lock
)
.finish
()
}
}
...
...
@@ -520,7 +520,7 @@ impl<T: ?Sized> Deref for RwLockReadGuard<'_, T> {
type
Target
=
T
;
fn
deref
(
&
self
)
->
&
T
{
unsafe
{
&*
self
.
__
lock.data
.get
()
}
unsafe
{
&*
self
.lock.data
.get
()
}
}
}
...
...
@@ -529,29 +529,29 @@ impl<T: ?Sized> Deref for RwLockWriteGuard<'_, T> {
type
Target
=
T
;
fn
deref
(
&
self
)
->
&
T
{
unsafe
{
&*
self
.
__
lock.data
.get
()
}
unsafe
{
&*
self
.lock.data
.get
()
}
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
:
?
Sized
>
DerefMut
for
RwLockWriteGuard
<
'_
,
T
>
{
fn
deref_mut
(
&
mut
self
)
->
&
mut
T
{
unsafe
{
&
mut
*
self
.
__
lock.data
.get
()
}
unsafe
{
&
mut
*
self
.lock.data
.get
()
}
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
:
?
Sized
>
Drop
for
RwLockReadGuard
<
'_
,
T
>
{
fn
drop
(
&
mut
self
)
{
unsafe
{
self
.
__
lock.inner
.read_unlock
();
}
unsafe
{
self
.lock.inner
.read_unlock
();
}
}
}
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
impl
<
T
:
?
Sized
>
Drop
for
RwLockWriteGuard
<
'_
,
T
>
{
fn
drop
(
&
mut
self
)
{
self
.
__lock.poison
.done
(
&
self
.__
poison
);
unsafe
{
self
.
__
lock.inner
.write_unlock
();
}
self
.
lock.poison
.done
(
&
self
.
poison
);
unsafe
{
self
.lock.inner
.write_unlock
();
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录