Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ac5aa1de
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,发现更多精彩内容 >>
提交
ac5aa1de
编写于
6月 03, 2022
作者:
M
Mara Bos
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use Drop instead of destroy() for locks.
上级
fb197601
变更
24
显示空白变更内容
内联
并排
Showing
24 changed file
with
39 addition
and
87 deletion
+39
-87
library/std/src/sys/hermit/condvar.rs
library/std/src/sys/hermit/condvar.rs
+7
-3
library/std/src/sys/hermit/mutex.rs
library/std/src/sys/hermit/mutex.rs
+0
-3
library/std/src/sys/hermit/rwlock.rs
library/std/src/sys/hermit/rwlock.rs
+0
-6
library/std/src/sys/itron/condvar.rs
library/std/src/sys/itron/condvar.rs
+0
-2
library/std/src/sys/itron/mutex.rs
library/std/src/sys/itron/mutex.rs
+3
-1
library/std/src/sys/sgx/condvar.rs
library/std/src/sys/sgx/condvar.rs
+0
-3
library/std/src/sys/sgx/mutex.rs
library/std/src/sys/sgx/mutex.rs
+0
-3
library/std/src/sys/sgx/rwlock.rs
library/std/src/sys/sgx/rwlock.rs
+0
-3
library/std/src/sys/solid/rwlock.rs
library/std/src/sys/solid/rwlock.rs
+3
-1
library/std/src/sys/unix/locks/futex.rs
library/std/src/sys/unix/locks/futex.rs
+0
-6
library/std/src/sys/unix/locks/futex_rwlock.rs
library/std/src/sys/unix/locks/futex_rwlock.rs
+0
-3
library/std/src/sys/unix/locks/pthread_condvar.rs
library/std/src/sys/unix/locks/pthread_condvar.rs
+9
-2
library/std/src/sys/unix/locks/pthread_mutex.rs
library/std/src/sys/unix/locks/pthread_mutex.rs
+9
-2
library/std/src/sys/unix/locks/pthread_rwlock.rs
library/std/src/sys/unix/locks/pthread_rwlock.rs
+8
-1
library/std/src/sys/unsupported/locks/condvar.rs
library/std/src/sys/unsupported/locks/condvar.rs
+0
-3
library/std/src/sys/unsupported/locks/mutex.rs
library/std/src/sys/unsupported/locks/mutex.rs
+0
-3
library/std/src/sys/unsupported/locks/rwlock.rs
library/std/src/sys/unsupported/locks/rwlock.rs
+0
-3
library/std/src/sys/windows/locks/condvar.rs
library/std/src/sys/windows/locks/condvar.rs
+0
-4
library/std/src/sys/windows/locks/mutex.rs
library/std/src/sys/windows/locks/mutex.rs
+0
-5
library/std/src/sys/windows/locks/rwlock.rs
library/std/src/sys/windows/locks/rwlock.rs
+0
-5
library/std/src/sys_common/condvar.rs
library/std/src/sys_common/condvar.rs
+0
-6
library/std/src/sys_common/mutex.rs
library/std/src/sys_common/mutex.rs
+0
-6
library/std/src/sys_common/remutex.rs
library/std/src/sys_common/remutex.rs
+0
-7
library/std/src/sys_common/rwlock.rs
library/std/src/sys_common/rwlock.rs
+0
-6
未找到文件。
library/std/src/sys/hermit/condvar.rs
浏览文件 @
ac5aa1de
...
...
@@ -70,9 +70,13 @@ pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
mutex
.lock
();
res
==
0
}
}
pub
unsafe
fn
destroy
(
&
self
)
{
impl
Drop
for
Condvar
{
fn
drop
(
&
mut
self
)
{
unsafe
{
let
_
=
abi
::
sem_destroy
(
self
.sem1
);
let
_
=
abi
::
sem_destroy
(
self
.sem2
);
}
}
}
library/std/src/sys/hermit/mutex.rs
浏览文件 @
ac5aa1de
...
...
@@ -215,7 +215,4 @@ pub unsafe fn try_lock(&self) -> bool {
}
guard
.locked
}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{}
}
library/std/src/sys/hermit/rwlock.rs
浏览文件 @
ac5aa1de
...
...
@@ -84,12 +84,6 @@ pub unsafe fn write_unlock(&self) {
// FIXME: should only wake up one of these some of the time
self
.cond
.notify_all
();
}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{
self
.lock
.destroy
();
self
.cond
.destroy
();
}
}
impl
State
{
...
...
library/std/src/sys/itron/condvar.rs
浏览文件 @
ac5aa1de
...
...
@@ -117,8 +117,6 @@ pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
unsafe
{
mutex
.lock
()
};
success
}
pub
unsafe
fn
destroy
(
&
self
)
{}
}
mod
waiter_queue
{
...
...
library/std/src/sys/itron/mutex.rs
浏览文件 @
ac5aa1de
...
...
@@ -64,8 +64,10 @@ pub unsafe fn try_lock(&self) -> bool {
}
}
}
}
pub
unsafe
fn
destroy
(
&
self
)
{
impl
Drop
for
Mutex
{
fn
drop
(
&
mut
self
)
{
if
let
Some
(
mtx
)
=
self
.mtx
.get
()
.map
(|
x
|
x
.0
)
{
expect_success_aborting
(
unsafe
{
abi
::
del_mtx
(
mtx
)
},
&
"del_mtx"
);
}
...
...
library/std/src/sys/sgx/condvar.rs
浏览文件 @
ac5aa1de
...
...
@@ -38,7 +38,4 @@ pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
unsafe
{
mutex
.lock
()
};
success
}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{}
}
library/std/src/sys/sgx/mutex.rs
浏览文件 @
ac5aa1de
...
...
@@ -52,7 +52,4 @@ pub unsafe fn try_lock(&self) -> bool {
true
}
}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{}
}
library/std/src/sys/sgx/rwlock.rs
浏览文件 @
ac5aa1de
...
...
@@ -168,9 +168,6 @@ unsafe fn unlock(&self) {
unsafe
{
self
.__read_unlock
(
rguard
,
wguard
)
};
}
}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{}
}
// The following functions are needed by libunwind. These symbols are named
...
...
library/std/src/sys/solid/rwlock.rs
浏览文件 @
ac5aa1de
...
...
@@ -82,9 +82,11 @@ pub unsafe fn write_unlock(&self) {
let
rwl
=
self
.raw
();
expect_success_aborting
(
unsafe
{
abi
::
rwl_unl_rwl
(
rwl
)
},
&
"rwl_unl_rwl"
);
}
}
impl
Drop
for
RwLock
{
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{
fn
drop
(
&
mut
self
)
{
if
let
Some
(
rwl
)
=
self
.rwl
.get
()
.map
(|
x
|
x
.0
)
{
expect_success_aborting
(
unsafe
{
abi
::
rwl_del_rwl
(
rwl
)
},
&
"rwl_del_rwl"
);
}
...
...
library/std/src/sys/unix/locks/futex.rs
浏览文件 @
ac5aa1de
...
...
@@ -24,9 +24,6 @@ pub const fn new() -> Self {
#[inline]
pub
unsafe
fn
init
(
&
mut
self
)
{}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{}
#[inline]
pub
unsafe
fn
try_lock
(
&
self
)
->
bool
{
self
.futex
.compare_exchange
(
0
,
1
,
Acquire
,
Relaxed
)
.is_ok
()
...
...
@@ -121,9 +118,6 @@ pub const fn new() -> Self {
#[inline]
pub
unsafe
fn
init
(
&
mut
self
)
{}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{}
// All the memory orderings here are `Relaxed`,
// because synchronization is done by unlocking and locking the mutex.
...
...
library/std/src/sys/unix/locks/futex_rwlock.rs
浏览文件 @
ac5aa1de
...
...
@@ -63,9 +63,6 @@ pub const fn new() -> Self {
Self
{
state
:
AtomicU32
::
new
(
0
),
writer_notify
:
AtomicU32
::
new
(
0
)
}
}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{}
#[inline]
pub
unsafe
fn
try_read
(
&
self
)
->
bool
{
self
.state
...
...
library/std/src/sys/unix/locks/pthread_condvar.rs
浏览文件 @
ac5aa1de
...
...
@@ -179,14 +179,14 @@ pub unsafe fn wait_timeout(&self, mutex: &Mutex, mut dur: Duration) -> bool {
#[inline]
#[cfg(not(target_os
=
"dragonfly"
))]
pub
unsafe
fn
destroy
(
&
self
)
{
unsafe
fn
destroy
(
&
mut
self
)
{
let
r
=
libc
::
pthread_cond_destroy
(
self
.inner
.get
());
debug_assert_eq!
(
r
,
0
);
}
#[inline]
#[cfg(target_os
=
"dragonfly"
)]
pub
unsafe
fn
destroy
(
&
self
)
{
unsafe
fn
destroy
(
&
mut
self
)
{
let
r
=
libc
::
pthread_cond_destroy
(
self
.inner
.get
());
// On DragonFly pthread_cond_destroy() returns EINVAL if called on
// a condvar that was just initialized with
...
...
@@ -195,3 +195,10 @@ pub unsafe fn destroy(&self) {
debug_assert!
(
r
==
0
||
r
==
libc
::
EINVAL
);
}
}
impl
Drop
for
Condvar
{
#[inline]
fn
drop
(
&
mut
self
)
{
unsafe
{
self
.destroy
()
};
}
}
library/std/src/sys/unix/locks/pthread_mutex.rs
浏览文件 @
ac5aa1de
...
...
@@ -73,13 +73,13 @@ pub unsafe fn try_lock(&self) -> bool {
}
#[inline]
#[cfg(not(target_os
=
"dragonfly"
))]
pub
unsafe
fn
destroy
(
&
self
)
{
unsafe
fn
destroy
(
&
mut
self
)
{
let
r
=
libc
::
pthread_mutex_destroy
(
self
.inner
.get
());
debug_assert_eq!
(
r
,
0
);
}
#[inline]
#[cfg(target_os
=
"dragonfly"
)]
pub
unsafe
fn
destroy
(
&
self
)
{
unsafe
fn
destroy
(
&
mut
self
)
{
let
r
=
libc
::
pthread_mutex_destroy
(
self
.inner
.get
());
// On DragonFly pthread_mutex_destroy() returns EINVAL if called on a
// mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER.
...
...
@@ -89,6 +89,13 @@ pub unsafe fn destroy(&self) {
}
}
impl
Drop
for
Mutex
{
#[inline]
fn
drop
(
&
mut
self
)
{
unsafe
{
self
.destroy
()
};
}
}
pub
(
super
)
struct
PthreadMutexAttr
<
'a
>
(
pub
&
'a
mut
MaybeUninit
<
libc
::
pthread_mutexattr_t
>
);
impl
Drop
for
PthreadMutexAttr
<
'_
>
{
...
...
library/std/src/sys/unix/locks/pthread_rwlock.rs
浏览文件 @
ac5aa1de
...
...
@@ -128,7 +128,7 @@ pub unsafe fn write_unlock(&self) {
self
.raw_unlock
();
}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{
unsafe
fn
destroy
(
&
mut
self
)
{
let
r
=
libc
::
pthread_rwlock_destroy
(
self
.inner
.get
());
// On DragonFly pthread_rwlock_destroy() returns EINVAL if called on a
// rwlock that was just initialized with
...
...
@@ -141,3 +141,10 @@ pub unsafe fn destroy(&self) {
}
}
}
impl
Drop
for
RwLock
{
#[inline]
fn
drop
(
&
mut
self
)
{
unsafe
{
self
.destroy
()
};
}
}
library/std/src/sys/unsupported/locks/condvar.rs
浏览文件 @
ac5aa1de
...
...
@@ -26,7 +26,4 @@ pub unsafe fn wait(&self, _mutex: &Mutex) {
pub
unsafe
fn
wait_timeout
(
&
self
,
_
mutex
:
&
Mutex
,
_
dur
:
Duration
)
->
bool
{
panic!
(
"condvar wait not supported"
);
}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{}
}
library/std/src/sys/unsupported/locks/mutex.rs
浏览文件 @
ac5aa1de
...
...
@@ -32,7 +32,4 @@ pub unsafe fn unlock(&self) {
pub
unsafe
fn
try_lock
(
&
self
)
->
bool
{
self
.locked
.replace
(
true
)
==
false
}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{}
}
library/std/src/sys/unsupported/locks/rwlock.rs
浏览文件 @
ac5aa1de
...
...
@@ -62,7 +62,4 @@ pub unsafe fn read_unlock(&self) {
pub
unsafe
fn
write_unlock
(
&
self
)
{
assert_eq!
(
self
.mode
.replace
(
0
),
-
1
);
}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{}
}
library/std/src/sys/windows/locks/condvar.rs
浏览文件 @
ac5aa1de
...
...
@@ -51,8 +51,4 @@ pub unsafe fn notify_one(&self) {
pub
unsafe
fn
notify_all
(
&
self
)
{
c
::
WakeAllConditionVariable
(
self
.inner
.get
())
}
pub
unsafe
fn
destroy
(
&
self
)
{
// ...
}
}
library/std/src/sys/windows/locks/mutex.rs
浏览文件 @
ac5aa1de
...
...
@@ -53,9 +53,4 @@ pub unsafe fn try_lock(&self) -> bool {
pub
unsafe
fn
unlock
(
&
self
)
{
c
::
ReleaseSRWLockExclusive
(
raw
(
self
));
}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{
// SRWLock does not need to be destroyed.
}
}
library/std/src/sys/windows/locks/rwlock.rs
浏览文件 @
ac5aa1de
...
...
@@ -38,9 +38,4 @@ pub unsafe fn read_unlock(&self) {
pub
unsafe
fn
write_unlock
(
&
self
)
{
c
::
ReleaseSRWLockExclusive
(
self
.inner
.get
())
}
#[inline]
pub
unsafe
fn
destroy
(
&
self
)
{
// ...
}
}
library/std/src/sys_common/condvar.rs
浏览文件 @
ac5aa1de
...
...
@@ -55,9 +55,3 @@ pub unsafe fn wait_timeout(&self, mutex: &MovableMutex, dur: Duration) -> bool {
self
.inner
.wait_timeout
(
mutex
.raw
(),
dur
)
}
}
impl
Drop
for
Condvar
{
fn
drop
(
&
mut
self
)
{
unsafe
{
self
.inner
.destroy
()
};
}
}
library/std/src/sys_common/mutex.rs
浏览文件 @
ac5aa1de
...
...
@@ -92,9 +92,3 @@ pub unsafe fn raw_unlock(&self) {
self
.0
.unlock
()
}
}
impl
Drop
for
MovableMutex
{
fn
drop
(
&
mut
self
)
{
unsafe
{
self
.0
.destroy
()
};
}
}
library/std/src/sys_common/remutex.rs
浏览文件 @
ac5aa1de
...
...
@@ -168,13 +168,6 @@ unsafe fn increment_lock_count(&self) {
}
}
impl
<
T
>
Drop
for
ReentrantMutex
<
T
>
{
fn
drop
(
&
mut
self
)
{
// Safety: We're the unique owner of this mutex and not going to use it afterwards.
unsafe
{
self
.mutex
.destroy
()
}
}
}
impl
<
T
>
Deref
for
ReentrantMutexGuard
<
'_
,
T
>
{
type
Target
=
T
;
...
...
library/std/src/sys_common/rwlock.rs
浏览文件 @
ac5aa1de
...
...
@@ -126,9 +126,3 @@ pub unsafe fn write_unlock(&self) {
self
.0
.write_unlock
()
}
}
impl
Drop
for
MovableRwLock
{
fn
drop
(
&
mut
self
)
{
unsafe
{
self
.0
.destroy
()
};
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录