Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
bc2d1478
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,发现更多精彩内容 >>
提交
bc2d1478
编写于
2月 12, 2013
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
auto merge of #4858 : z0w0/rust/rm_weak_task_count, r=graydon
上级
21a0d52a
0db527e2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
26 addition
and
45 deletion
+26
-45
src/libcore/private/weak_task.rs
src/libcore/private/weak_task.rs
+6
-6
src/rt/rust_builtin.cpp
src/rt/rust_builtin.cpp
+4
-4
src/rt/rust_kernel.cpp
src/rt/rust_kernel.cpp
+10
-27
src/rt/rust_kernel.h
src/rt/rust_kernel.h
+2
-4
src/rt/rust_scheduler.cpp
src/rt/rust_scheduler.cpp
+2
-2
src/rt/rustrt.def.in
src/rt/rustrt.def.in
+2
-2
未找到文件。
src/libcore/private/weak_task.rs
浏览文件 @
bc2d1478
...
...
@@ -41,12 +41,12 @@ pub unsafe fn weaken_task(f: &fn(Port<ShutdownMsg>)) {
let
task
=
get_task_id
();
// Expect the weak task service to be alive
assert
service
.try_send
(
RegisterWeakTask
(
task
,
shutdown_chan
));
unsafe
{
rust_
inc_weak_task
_count
();
}
unsafe
{
rust_
dec_kernel_live
_count
();
}
do
fn
&
()
{
let
shutdown_port
=
swap_unwrap
(
&
mut
*
shutdown_port
);
f
(
shutdown_port
)
}
.finally
||
{
unsafe
{
rust_
dec_weak_task
_count
();
}
unsafe
{
rust_
inc_kernel_live
_count
();
}
// Service my have already exited
service
.send
(
UnregisterWeakTask
(
task
));
}
...
...
@@ -79,11 +79,11 @@ fn create_global_service() -> ~WeakTaskService {
let
port
=
swap_unwrap
(
&
mut
*
port
);
// The weak task service is itself a weak task
debug!
(
"weakening the weak service task"
);
unsafe
{
rust_
inc_weak_task
_count
();
}
unsafe
{
rust_
dec_kernel_live
_count
();
}
run_weak_task_service
(
port
);
}
.finally
{
debug!
(
"unweakening the weak service task"
);
unsafe
{
rust_
dec_weak_task
_count
();
}
unsafe
{
rust_
inc_kernel_live
_count
();
}
}
}
...
...
@@ -127,8 +127,8 @@ fn run_weak_task_service(port: Port<ServiceMsg>) {
}
extern
{
unsafe
fn
rust_inc_
weak_task
_count
();
unsafe
fn
rust_dec_
weak_task
_count
();
unsafe
fn
rust_inc_
kernel_live
_count
();
unsafe
fn
rust_dec_
kernel_live
_count
();
}
#[test]
...
...
src/rt/rust_builtin.cpp
浏览文件 @
bc2d1478
...
...
@@ -939,15 +939,15 @@ rust_get_global_data_ptr() {
}
extern
"C"
void
rust_inc_
weak_task
_count
()
{
rust_inc_
kernel_live
_count
()
{
rust_task
*
task
=
rust_get_current_task
();
task
->
kernel
->
inc_
weak_task
_count
();
task
->
kernel
->
inc_
live
_count
();
}
extern
"C"
void
rust_dec_
weak_task
_count
()
{
rust_dec_
kernel_live
_count
()
{
rust_task
*
task
=
rust_get_current_task
();
task
->
kernel
->
dec_
weak_task
_count
();
task
->
kernel
->
dec_
live
_count
();
}
//
...
...
src/rt/rust_kernel.cpp
浏览文件 @
bc2d1478
...
...
@@ -291,12 +291,20 @@ rust_kernel::set_exit_status(int code) {
}
void
rust_kernel
::
register_task
()
{
KLOG_
(
"Registering task"
);
rust_kernel
::
inc_live_count
()
{
uintptr_t
new_non_weak_tasks
=
sync
::
increment
(
non_weak_tasks
);
KLOG_
(
"New non-weak tasks %"
PRIdPTR
,
new_non_weak_tasks
);
}
void
rust_kernel
::
dec_live_count
()
{
uintptr_t
new_non_weak_tasks
=
sync
::
decrement
(
non_weak_tasks
);
KLOG_
(
"New non-weak tasks %"
PRIdPTR
,
new_non_weak_tasks
);
if
(
new_non_weak_tasks
==
0
)
{
begin_shutdown
();
}
}
void
rust_kernel
::
allow_scheduler_exit
()
{
scoped_lock
with
(
sched_lock
);
...
...
@@ -315,31 +323,6 @@ rust_kernel::allow_scheduler_exit() {
osmain_sched
->
allow_exit
();
}
void
rust_kernel
::
unregister_task
()
{
KLOG_
(
"Unregistering task"
);
uintptr_t
new_non_weak_tasks
=
sync
::
decrement
(
non_weak_tasks
);
KLOG_
(
"New non-weak tasks %"
PRIdPTR
,
new_non_weak_tasks
);
if
(
new_non_weak_tasks
==
0
)
{
begin_shutdown
();
}
}
void
rust_kernel
::
inc_weak_task_count
()
{
uintptr_t
new_non_weak_tasks
=
sync
::
decrement
(
non_weak_tasks
);
KLOG_
(
"New non-weak tasks %"
PRIdPTR
,
new_non_weak_tasks
);
if
(
new_non_weak_tasks
==
0
)
{
begin_shutdown
();
}
}
void
rust_kernel
::
dec_weak_task_count
()
{
uintptr_t
new_non_weak_tasks
=
sync
::
increment
(
non_weak_tasks
);
KLOG_
(
"New non-weak tasks %"
PRIdPTR
,
new_non_weak_tasks
);
}
void
rust_kernel
::
begin_shutdown
()
{
{
...
...
src/rt/rust_kernel.h
浏览文件 @
bc2d1478
...
...
@@ -160,10 +160,8 @@ public:
rust_sched_id
main_sched_id
()
{
return
main_scheduler
;
}
rust_sched_id
osmain_sched_id
()
{
return
osmain_scheduler
;
}
void
register_task
();
void
unregister_task
();
void
inc_weak_task_count
();
void
dec_weak_task_count
();
void
inc_live_count
();
void
dec_live_count
();
void
register_exit_function
(
spawn_fn
runner
,
fn_env_pair
*
f
);
};
...
...
src/rt/rust_scheduler.cpp
浏览文件 @
bc2d1478
...
...
@@ -123,7 +123,7 @@ rust_scheduler::create_task(rust_task *spawner, const char *name) {
cur_thread
=
(
thread_no
+
1
)
%
max_num_threads
;
}
KLOG
(
kernel
,
kern
,
"Creating task %s, on thread %d."
,
name
,
thread_no
);
kernel
->
register_task
();
kernel
->
inc_live_count
();
rust_sched_launcher
*
thread
=
threads
[
thread_no
];
return
thread
->
get_loop
()
->
create_task
(
spawner
,
name
);
}
...
...
@@ -138,7 +138,7 @@ rust_scheduler::release_task() {
need_exit
=
true
;
}
}
kernel
->
unregister_task
();
kernel
->
dec_live_count
();
if
(
need_exit
)
{
exit
();
}
...
...
src/rt/rustrt.def.in
浏览文件 @
bc2d1478
...
...
@@ -188,6 +188,6 @@ rust_raw_thread_start
rust_raw_thread_join_delete
rust_register_exit_function
rust_get_global_data_ptr
rust_inc_
weak_task
_count
rust_dec_
weak_task
_count
rust_inc_
kernel_live
_count
rust_dec_
kernel_live
_count
rust_get_exchange_count_ptr
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录