Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b5dd01eb
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,发现更多精彩内容 >>
提交
b5dd01eb
编写于
8月 24, 2012
作者:
M
Michael Sullivan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a bunch more unsafe blocks to prepare for the new semantics of unsafe/closure interactions.
上级
2c96a43c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
32 addition
and
30 deletion
+32
-30
src/libcore/task.rs
src/libcore/task.rs
+5
-5
src/libstd/net_ip.rs
src/libstd/net_ip.rs
+3
-3
src/libstd/net_tcp.rs
src/libstd/net_tcp.rs
+9
-9
src/libstd/timer.rs
src/libstd/timer.rs
+1
-1
src/libstd/uv_global_loop.rs
src/libstd/uv_global_loop.rs
+13
-11
src/libstd/uv_iotask.rs
src/libstd/uv_iotask.rs
+1
-1
未找到文件。
src/libcore/task.rs
浏览文件 @
b5dd01eb
...
...
@@ -2089,7 +2089,7 @@ fn child_no(x: uint) -> fn~() {
fn
test_tls_multitask
()
unsafe
{
fn
my_key
(
+
_
x
:
@~
str
)
{
}
local_data_set
(
my_key
,
@~
"parent data"
);
do
task
::
spawn
{
do
task
::
spawn
unsafe
{
assert
local_data_get
(
my_key
)
==
none
;
// TLS shouldn't carry over.
local_data_set
(
my_key
,
@~
"child data"
);
assert
*
(
local_data_get
(
my_key
)
.get
())
==
~
"child data"
;
...
...
@@ -2155,7 +2155,7 @@ fn test_tls_multiple_types() unsafe {
fn
str_key
(
+
_
x
:
@~
str
)
{
}
fn
box_key
(
+
_
x
:
@@
())
{
}
fn
int_key
(
+
_
x
:
@
int
)
{
}
do
task
::
spawn
{
do
task
::
spawn
unsafe
{
local_data_set
(
str_key
,
@~
"string data"
);
local_data_set
(
box_key
,
@@
());
local_data_set
(
int_key
,
@
42
);
...
...
@@ -2163,11 +2163,11 @@ fn int_key(+_x: @int) { }
}
#[test]
fn
test_tls_overwrite_multiple_types
()
unsafe
{
fn
test_tls_overwrite_multiple_types
()
{
fn
str_key
(
+
_
x
:
@~
str
)
{
}
fn
box_key
(
+
_
x
:
@@
())
{
}
fn
int_key
(
+
_
x
:
@
int
)
{
}
do
task
::
spawn
{
do
task
::
spawn
unsafe
{
local_data_set
(
str_key
,
@~
"string data"
);
local_data_set
(
int_key
,
@
42
);
// This could cause a segfault if overwriting-destruction is done with
...
...
@@ -2185,7 +2185,7 @@ fn box_key(+_x: @@()) { }
fn
int_key
(
+
_
x
:
@
int
)
{
}
local_data_set
(
str_key
,
@~
"parent data"
);
local_data_set
(
box_key
,
@@
());
do
task
::
spawn
{
// spawn_linked
do
task
::
spawn
unsafe
{
// spawn_linked
local_data_set
(
str_key
,
@~
"string data"
);
local_data_set
(
box_key
,
@@
());
local_data_set
(
int_key
,
@
42
);
...
...
src/libstd/net_ip.rs
浏览文件 @
b5dd01eb
...
...
@@ -85,9 +85,9 @@ enum ip_get_addr_err {
* object in the case of failure
*/
fn
get_addr
(
++
node
:
~
str
,
iotask
:
iotask
)
->
result
::
result
<~
[
ip_addr
],
ip_get_addr_err
>
unsafe
{
->
result
::
result
<~
[
ip_addr
],
ip_get_addr_err
>
{
do
core
::
comm
::
listen
|
output_ch
|
{
do
str
::
as_buf
(
node
)
|
node_ptr
,
len
|
{
do
str
::
as_buf
(
node
)
|
node_ptr
,
len
|
unsafe
{
log
(
debug
,
fmt!
(
"slice len %?"
,
len
));
let
handle
=
create_uv_getaddrinfo_t
();
let
handle_ptr
=
ptr
::
addr_of
(
handle
);
...
...
@@ -95,7 +95,7 @@ fn get_addr(++node: ~str, iotask: iotask)
output_ch
:
output_ch
};
let
handle_data_ptr
=
ptr
::
addr_of
(
handle_data
);
do
interact
(
iotask
)
|
loop_ptr
|
{
do
interact
(
iotask
)
|
loop_ptr
|
unsafe
{
let
result
=
uv_getaddrinfo
(
loop_ptr
,
handle_ptr
,
...
...
src/libstd/net_tcp.rs
浏览文件 @
b5dd01eb
...
...
@@ -145,7 +145,7 @@ fn connect(-input_ip: ip::ip_addr, port: uint,
// we can send into the interact cb to be handled in libuv..
log
(
debug
,
fmt!
(
"stream_handle_ptr outside interact %?"
,
stream_handle_ptr
));
do
iotask
::
interact
(
iotask
)
|
loop_ptr
|
{
do
iotask
::
interact
(
iotask
)
|
loop_ptr
|
unsafe
{
log
(
debug
,
~
"in interact cb for tcp client connect.."
);
log
(
debug
,
fmt!
(
"stream_handle_ptr in interact %?"
,
stream_handle_ptr
));
...
...
@@ -571,7 +571,7 @@ fn listen(-host_ip: ip::ip_addr, port: uint, backlog: uint,
->
result
::
result
<
(),
tcp_listen_err_data
>
unsafe
{
do
listen_common
(
host_ip
,
port
,
backlog
,
iotask
,
on_establish_cb
)
// on_connect_cb
|
handle
|
{
|
handle
|
unsafe
{
let
server_data_ptr
=
uv
::
ll
::
get_data_for_uv_handle
(
handle
)
as
*
tcp_listen_fc_data
;
let
new_conn
=
new_tcp_conn
(
handle
);
...
...
@@ -608,7 +608,7 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint,
// tcp::connect (because the iotask::interact cb isn't
// nested within a core::comm::listen block)
let
loc_ip
=
copy
(
host_ip
);
do
iotask
::
interact
(
iotask
)
|
loop_ptr
|
{
do
iotask
::
interact
(
iotask
)
|
loop_ptr
|
unsafe
{
match
uv
::
ll
::
tcp_init
(
loop_ptr
,
server_stream_ptr
)
{
0i32
=>
{
uv
::
ll
::
set_data_for_uv_handle
(
...
...
@@ -660,7 +660,7 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint,
};
match
setup_result
{
some
(
err_data
)
=>
{
do
iotask
::
interact
(
iotask
)
|
loop_ptr
|
{
do
iotask
::
interact
(
iotask
)
|
loop_ptr
|
unsafe
{
log
(
debug
,
fmt!
(
"tcp::listen post-kill recv hl interact %?"
,
loop_ptr
));
(
*
server_data_ptr
)
.active
=
false
;
...
...
@@ -687,7 +687,7 @@ fn listen_common(-host_ip: ip::ip_addr, port: uint, backlog: uint,
none
=>
{
on_establish_cb
(
kill_ch
);
let
kill_result
=
core
::
comm
::
recv
(
kill_po
);
do
iotask
::
interact
(
iotask
)
|
loop_ptr
|
{
do
iotask
::
interact
(
iotask
)
|
loop_ptr
|
unsafe
{
log
(
debug
,
fmt!
(
"tcp::listen post-kill recv hl interact %?"
,
loop_ptr
));
(
*
server_data_ptr
)
.active
=
false
;
...
...
@@ -844,7 +844,7 @@ fn tear_down_socket_data(socket_data: @tcp_socket_data) unsafe {
};
let
close_data_ptr
=
ptr
::
addr_of
(
close_data
);
let
stream_handle_ptr
=
(
*
socket_data
)
.stream_handle_ptr
;
do
iotask
::
interact
((
*
socket_data
)
.iotask
)
|
loop_ptr
|
{
do
iotask
::
interact
((
*
socket_data
)
.iotask
)
|
loop_ptr
|
unsafe
{
log
(
debug
,
fmt!
(
"interact dtor for tcp_socket stream %? loop %?"
,
stream_handle_ptr
,
loop_ptr
));
uv
::
ll
::
set_data_for_uv_handle
(
stream_handle_ptr
,
...
...
@@ -902,7 +902,7 @@ fn read_stop_common_impl(socket_data: *tcp_socket_data) ->
let
stream_handle_ptr
=
(
*
socket_data
)
.stream_handle_ptr
;
let
stop_po
=
core
::
comm
::
port
::
<
option
<
tcp_err_data
>>
();
let
stop_ch
=
core
::
comm
::
chan
(
stop_po
);
do
iotask
::
interact
((
*
socket_data
)
.iotask
)
|
loop_ptr
|
{
do
iotask
::
interact
((
*
socket_data
)
.iotask
)
|
loop_ptr
|
unsafe
{
log
(
debug
,
~
"in interact cb for tcp::read_stop"
);
match
uv
::
ll
::
read_stop
(
stream_handle_ptr
as
*
uv
::
ll
::
uv_stream_t
)
{
0i32
=>
{
...
...
@@ -930,7 +930,7 @@ fn read_start_common_impl(socket_data: *tcp_socket_data)
let
start_po
=
core
::
comm
::
port
::
<
option
<
uv
::
ll
::
uv_err_data
>>
();
let
start_ch
=
core
::
comm
::
chan
(
start_po
);
log
(
debug
,
~
"in tcp::read_start before interact loop"
);
do
iotask
::
interact
((
*
socket_data
)
.iotask
)
|
loop_ptr
|
{
do
iotask
::
interact
((
*
socket_data
)
.iotask
)
|
loop_ptr
|
unsafe
{
log
(
debug
,
fmt!
(
"in tcp::read_start interact cb %?"
,
loop_ptr
));
match
uv
::
ll
::
read_start
(
stream_handle_ptr
as
*
uv
::
ll
::
uv_stream_t
,
on_alloc_cb
,
...
...
@@ -970,7 +970,7 @@ fn write_common_impl(socket_data_ptr: *tcp_socket_data,
result_ch
:
core
::
comm
::
chan
(
result_po
)
};
let
write_data_ptr
=
ptr
::
addr_of
(
write_data
);
do
iotask
::
interact
((
*
socket_data_ptr
)
.iotask
)
|
loop_ptr
|
{
do
iotask
::
interact
((
*
socket_data_ptr
)
.iotask
)
|
loop_ptr
|
unsafe
{
log
(
debug
,
fmt!
(
"in interact cb for tcp::write %?"
,
loop_ptr
));
match
uv
::
ll
::
write
(
write_req_ptr
,
stream_handle_ptr
,
...
...
src/libstd/timer.rs
浏览文件 @
b5dd01eb
...
...
@@ -31,7 +31,7 @@ fn delayed_send<T: copy send>(iotask: iotask,
let
timer_done_ch_ptr
=
ptr
::
addr_of
(
timer_done_ch
);
let
timer
=
uv
::
ll
::
timer_t
();
let
timer_ptr
=
ptr
::
addr_of
(
timer
);
do
iotask
::
interact
(
iotask
)
|
loop_ptr
|
{
do
iotask
::
interact
(
iotask
)
|
loop_ptr
|
unsafe
{
let
init_result
=
uv
::
ll
::
timer_init
(
loop_ptr
,
timer_ptr
);
if
(
init_result
==
0i32
)
{
let
start_result
=
uv
::
ll
::
timer_start
(
...
...
src/libstd/uv_global_loop.rs
浏览文件 @
b5dd01eb
...
...
@@ -49,7 +49,7 @@ fn get_monitor_task_gl() -> iotask unsafe {
task
::
task
()
.sched_mode
(
task
::
SingleThreaded
)
.unlinked
()
})
|
msg_po
|
{
})
|
msg_po
|
unsafe
{
debug!
(
"global monitor task starting"
);
// As a weak task the runtime will notify us when to exit
...
...
@@ -85,20 +85,22 @@ fn get_monitor_task_gl() -> iotask unsafe {
}
}
fn
spawn_loop
()
->
iotask
unsafe
{
fn
spawn_loop
()
->
iotask
{
let
builder
=
do
task
::
task
()
.add_wrapper
|
task_body
|
{
fn
~
(
move
task_body
)
{
// The I/O loop task also needs to be weak so it doesn't keep
// the runtime alive
do
weaken_task
|
weak_exit_po
|
{
debug!
(
"global libuv task is now weak %?"
,
weak_exit_po
);
task_body
();
unsafe
{
do
weaken_task
|
weak_exit_po
|
{
debug!
(
"global libuv task is now weak %?"
,
weak_exit_po
);
task_body
();
// We don't wait for the exit message on weak_exit_po
// because the monitor task will tell the uv loop when to
// exit
// We don't wait for the exit message on weak_exit_po
// because the monitor task will tell the uv loop when to
// exit
debug!
(
"global libuv task is leaving weakened state"
);
debug!
(
"global libuv task is leaving weakened state"
);
}
}
}
};
...
...
@@ -120,7 +122,7 @@ mod test {
log
(
debug
,
~
"in simple timer cb"
);
ll
::
timer_stop
(
timer_ptr
);
let
hl_loop
=
get_gl
();
do
iotask
::
interact
(
hl_loop
)
|
_
loop_ptr
|
{
do
iotask
::
interact
(
hl_loop
)
|
_
loop_ptr
|
unsafe
{
log
(
debug
,
~
"closing timer"
);
ll
::
close
(
timer_ptr
,
simple_timer_close_cb
);
log
(
debug
,
~
"about to deref exit_ch_ptr"
);
...
...
@@ -137,7 +139,7 @@ fn impl_uv_hl_simple_timer(iotask: iotask) unsafe {
exit_ch_ptr
));
let
timer_handle
=
ll
::
timer_t
();
let
timer_ptr
=
ptr
::
addr_of
(
timer_handle
);
do
iotask
::
interact
(
iotask
)
|
loop_ptr
|
{
do
iotask
::
interact
(
iotask
)
|
loop_ptr
|
unsafe
{
log
(
debug
,
~
"user code inside interact loop!!!"
);
let
init_status
=
ll
::
timer_init
(
loop_ptr
,
timer_ptr
);
if
(
init_status
==
0i32
)
{
...
...
src/libstd/uv_iotask.rs
浏览文件 @
b5dd01eb
...
...
@@ -193,7 +193,7 @@ fn impl_uv_iotask_async(iotask: iotask) unsafe {
exit_ch
:
exit_ch
};
let
ah_data_ptr
=
ptr
::
addr_of
(
ah_data
);
do
interact
(
iotask
)
|
loop_ptr
|
{
do
interact
(
iotask
)
|
loop_ptr
|
unsafe
{
ll
::
async_init
(
loop_ptr
,
ah_ptr
,
async_handle_cb
);
ll
::
set_data_for_uv_handle
(
ah_ptr
,
ah_data_ptr
as
*
libc
::
c_void
);
ll
::
async_send
(
ah_ptr
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录