Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
94720fce
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,发现更多精彩内容 >>
提交
94720fce
编写于
8月 29, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
std: More camel casing
上级
d8b34b2a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
59 addition
and
50 deletion
+59
-50
src/libstd/net_ip.rs
src/libstd/net_ip.rs
+1
-1
src/libstd/net_tcp.rs
src/libstd/net_tcp.rs
+9
-9
src/libstd/std.rc
src/libstd/std.rc
+7
-0
src/libstd/timer.rs
src/libstd/timer.rs
+4
-4
src/libstd/uv_global_loop.rs
src/libstd/uv_global_loop.rs
+7
-7
src/libstd/uv_iotask.rs
src/libstd/uv_iotask.rs
+29
-29
src/libstd/uv_ll.rs
src/libstd/uv_ll.rs
+2
-0
未找到文件。
src/libstd/net_ip.rs
浏览文件 @
94720fce
...
...
@@ -2,7 +2,7 @@
import
vec
;
import
uint
;
import
iotask
=
uv
::
iotask
::
iot
ask
;
import
iotask
=
uv
::
iotask
::
IoT
ask
;
import
interact
=
uv
::
iotask
::
interact
;
import
sockaddr_in
=
uv
::
ll
::
sockaddr_in
;
...
...
src/libstd/net_tcp.rs
浏览文件 @
94720fce
...
...
@@ -2,7 +2,7 @@
import
ip
=
net_ip
;
import
uv
::
iotask
;
import
uv
::
iotask
::
iot
ask
;
import
uv
::
iotask
::
IoT
ask
;
import
future_spawn
=
future
::
spawn
;
// FIXME #1935
// should be able to, but can't atm, replace w/ result::{result, extensions};
...
...
@@ -119,7 +119,7 @@ enum tcp_connect_err_data {
* `net::tcp::tcp_connect_err_data` instance will be returned
*/
fn
connect
(
-
input_ip
:
ip
::
ip_addr
,
port
:
uint
,
iotask
:
iot
ask
)
iotask
:
IoT
ask
)
->
result
::
Result
<
tcp_socket
,
tcp_connect_err_data
>
unsafe
{
let
result_po
=
core
::
comm
::
Port
::
<
conn_attempt
>
();
let
closed_signal_po
=
core
::
comm
::
Port
::
<
()
>
();
...
...
@@ -560,7 +560,7 @@ fn accept(new_conn: tcp_new_connection)
* of listen exiting because of an error
*/
fn
listen
(
-
host_ip
:
ip
::
ip_addr
,
port
:
uint
,
backlog
:
uint
,
iotask
:
iot
ask
,
iotask
:
IoT
ask
,
on_establish_cb
:
fn
~
(
comm
::
Chan
<
Option
<
tcp_err_data
>>
),
+
new_connect_cb
:
fn
~
(
tcp_new_connection
,
comm
::
Chan
<
Option
<
tcp_err_data
>>
))
...
...
@@ -577,7 +577,7 @@ fn listen(-host_ip: ip::ip_addr, port: uint, backlog: uint,
}
fn
listen_common
(
-
host_ip
:
ip
::
ip_addr
,
port
:
uint
,
backlog
:
uint
,
iotask
:
iot
ask
,
iotask
:
IoT
ask
,
on_establish_cb
:
fn
~
(
comm
::
Chan
<
Option
<
tcp_err_data
>>
),
-
on_connect_cb
:
fn
~
(
*
uv
::
ll
::
uv_tcp_t
))
->
result
::
Result
<
(),
tcp_listen_err_data
>
unsafe
{
...
...
@@ -1003,7 +1003,7 @@ enum tcp_new_connection {
stream_closed_ch
:
comm
::
Chan
<
()
>
,
kill_ch
:
comm
::
Chan
<
Option
<
tcp_err_data
>>
,
on_connect_cb
:
fn
~
(
*
uv
::
ll
::
uv_tcp_t
),
iotask
:
iot
ask
,
iotask
:
IoT
ask
,
mut
active
:
bool
};
...
...
@@ -1202,7 +1202,7 @@ enum conn_attempt {
stream_handle_ptr
:
*
uv
::
ll
::
uv_tcp_t
,
connect_req
:
uv
::
ll
::
uv_connect_t
,
write_req
:
uv
::
ll
::
uv_write_t
,
iotask
:
iot
ask
iotask
:
IoT
ask
};
type
tcp_buffered_socket_data
=
{
...
...
@@ -1479,7 +1479,7 @@ fn buf_read<R:io::Reader>(+r: &R, len: uint) -> ~str {
fn
run_tcp_test_server
(
server_ip
:
~
str
,
server_port
:
uint
,
resp
:
~
str
,
server_ch
:
comm
::
Chan
<~
str
>
,
cont_ch
:
comm
::
Chan
<
()
>
,
iotask
:
iot
ask
)
->
~
str
{
iotask
:
IoT
ask
)
->
~
str
{
let
server_ip_addr
=
ip
::
v4
::
parse_addr
(
server_ip
);
let
listen_result
=
listen
(
server_ip_addr
,
server_port
,
128u
,
iotask
,
// on_establish_cb -- called when listener is set up
...
...
@@ -1562,7 +1562,7 @@ fn run_tcp_test_server(server_ip: ~str, server_port: uint, resp: ~str,
}
fn
run_tcp_test_server_fail
(
server_ip
:
~
str
,
server_port
:
uint
,
iotask
:
iot
ask
)
->
tcp_listen_err_data
{
iotask
:
IoT
ask
)
->
tcp_listen_err_data
{
let
server_ip_addr
=
ip
::
v4
::
parse_addr
(
server_ip
);
let
listen_result
=
listen
(
server_ip_addr
,
server_port
,
128u
,
iotask
,
// on_establish_cb -- called when listener is set up
...
...
@@ -1585,7 +1585,7 @@ fn run_tcp_test_server_fail(server_ip: ~str, server_port: uint,
fn
run_tcp_test_client
(
server_ip
:
~
str
,
server_port
:
uint
,
resp
:
~
str
,
client_ch
:
comm
::
Chan
<~
str
>
,
iotask
:
iot
ask
)
->
result
::
Result
<~
str
,
iotask
:
IoT
ask
)
->
result
::
Result
<~
str
,
tcp_connect_err_data
>
{
let
server_ip_addr
=
ip
::
v4
::
parse_addr
(
server_ip
);
...
...
src/libstd/std.rc
浏览文件 @
94720fce
...
...
@@ -36,16 +36,22 @@ mod net_tcp;
mod net_url;
// libuv modules
#[warn(non_camel_case_types)]
mod uv;
mod uv_ll;
#[warn(non_camel_case_types)]
mod uv_iotask;
#[warn(non_camel_case_types)]
mod uv_global_loop;
// Utility modules
#[warn(non_camel_case_types)]
mod c_vec;
#[warn(non_camel_case_types)]
mod timer;
#[warn(non_camel_case_types)]
mod cell;
// Concurrency
...
...
@@ -54,6 +60,7 @@ mod cell;
mod sync;
#[warn(non_camel_case_types)]
mod arc;
#[warn(non_camel_case_types)]
mod comm;
// Collections
...
...
src/libstd/timer.rs
浏览文件 @
94720fce
...
...
@@ -5,7 +5,7 @@
import
uv
=
uv
;
import
uv
::
iotask
;
import
iotask
::
iot
ask
;
import
iotask
::
IoT
ask
;
import
comm
=
core
::
comm
;
export
delayed_send
,
sleep
,
recv_timeout
;
...
...
@@ -26,7 +26,7 @@
* * ch - a channel of type T to send a `val` on
* * val - a value of type T to send over the provided `ch`
*/
fn
delayed_send
<
T
:
copy
send
>
(
iotask
:
iot
ask
,
fn
delayed_send
<
T
:
copy
send
>
(
iotask
:
IoT
ask
,
msecs
:
uint
,
ch
:
comm
::
Chan
<
T
>
,
+
val
:
T
)
{
unsafe
{
let
timer_done_po
=
core
::
comm
::
Port
::
<
()
>
();
...
...
@@ -75,7 +75,7 @@ fn delayed_send<T: copy send>(iotask: iotask,
* * `iotask` - a `uv::iotask` that the tcp request will run on
* * msecs - an amount of time, in milliseconds, for the current task to block
*/
fn
sleep
(
iotask
:
iot
ask
,
msecs
:
uint
)
{
fn
sleep
(
iotask
:
IoT
ask
,
msecs
:
uint
)
{
let
exit_po
=
core
::
comm
::
Port
::
<
()
>
();
let
exit_ch
=
core
::
comm
::
Chan
(
exit_po
);
delayed_send
(
iotask
,
msecs
,
exit_ch
,
());
...
...
@@ -102,7 +102,7 @@ fn sleep(iotask: iotask, msecs: uint) {
* on the provided port in the allotted timeout period, then the result will
* be a `some(T)`. If not, then `none` will be returned.
*/
fn
recv_timeout
<
T
:
copy
send
>
(
iotask
:
iot
ask
,
fn
recv_timeout
<
T
:
copy
send
>
(
iotask
:
IoT
ask
,
msecs
:
uint
,
wait_po
:
comm
::
Port
<
T
>
)
->
Option
<
T
>
{
let
timeout_po
=
comm
::
Port
::
<
()
>
();
...
...
src/libstd/uv_global_loop.rs
浏览文件 @
94720fce
...
...
@@ -5,7 +5,7 @@
import
ll
=
uv_ll
;
import
iotask
=
uv_iotask
;
import
get_gl
=
get
;
import
iotask
::{
iot
ask
,
spawn_iotask
};
import
iotask
::{
IoT
ask
,
spawn_iotask
};
import
priv
::{
chan_from_global_ptr
,
weaken_task
};
import
comm
=
core
::
comm
;
import
comm
::{
Port
,
Chan
,
select2
,
listen
};
...
...
@@ -28,12 +28,12 @@
* * A `hl::high_level_loop` that encapsulates communication with the global
* loop.
*/
fn
get
()
->
iot
ask
{
fn
get
()
->
IoT
ask
{
return
get_monitor_task_gl
();
}
#[doc(hidden)]
fn
get_monitor_task_gl
()
->
iot
ask
unsafe
{
fn
get_monitor_task_gl
()
->
IoT
ask
unsafe
{
let
monitor_loop_chan_ptr
=
rustrt
::
rust_uv_get_kernel_global_chan_ptr
();
...
...
@@ -41,10 +41,10 @@ fn get_monitor_task_gl() -> iotask unsafe {
monitor_loop_chan_ptr
);
debug!
(
"before priv::chan_from_global_ptr"
);
type
monchan
=
Chan
<
iot
ask
>
;
type
MonChan
=
Chan
<
IoT
ask
>
;
let
monitor_ch
=
do
chan_from_global_ptr
::
<
monc
han
>
(
monitor_loop_chan_ptr
,
do
chan_from_global_ptr
::
<
MonC
han
>
(
monitor_loop_chan_ptr
,
||
{
task
::
task
()
.sched_mode
(
task
::
SingleThreaded
)
...
...
@@ -85,7 +85,7 @@ fn get_monitor_task_gl() -> iotask unsafe {
}
}
fn
spawn_loop
()
->
iot
ask
{
fn
spawn_loop
()
->
IoT
ask
{
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
...
...
@@ -131,7 +131,7 @@ mod test {
log
(
debug
,
~
"exiting simple timer cb"
);
}
fn
impl_uv_hl_simple_timer
(
iotask
:
iot
ask
)
unsafe
{
fn
impl_uv_hl_simple_timer
(
iotask
:
IoT
ask
)
unsafe
{
let
exit_po
=
core
::
comm
::
Port
::
<
bool
>
();
let
exit_ch
=
core
::
comm
::
Chan
(
exit_po
);
let
exit_ch_ptr
=
ptr
::
addr_of
(
exit_ch
);
...
...
src/libstd/uv_iotask.rs
浏览文件 @
94720fce
...
...
@@ -5,7 +5,7 @@
* `interact` function you can execute code in a uv callback.
*/
export
iot
ask
;
export
IoT
ask
;
export
spawn_iotask
;
export
interact
;
export
exit
;
...
...
@@ -18,14 +18,14 @@
import
ll
=
uv_ll
;
/// Used to abstract-away direct interaction with a libuv loop.
enum
iot
ask
{
iot
ask_
({
enum
IoT
ask
{
IoT
ask_
({
async_handle
:
*
ll
::
uv_async_t
,
op_chan
:
Chan
<
iotask_m
sg
>
op_chan
:
Chan
<
IoTaskM
sg
>
})
}
fn
spawn_iotask
(
-
task
:
task
::
TaskBuilder
)
->
iot
ask
{
fn
spawn_iotask
(
-
task
:
task
::
TaskBuilder
)
->
IoT
ask
{
do
listen
|
iotask_ch
|
{
...
...
@@ -62,9 +62,9 @@ fn spawn_iotask(-task: task::TaskBuilder) -> iotask {
* module. It is not safe to send the `loop_ptr` param to this callback out
* via ports/chans.
*/
unsafe
fn
interact
(
iotask
:
iot
ask
,
unsafe
fn
interact
(
iotask
:
IoT
ask
,
-
cb
:
fn
~
(
*
c_void
))
{
send_msg
(
iotask
,
i
nteraction
(
cb
));
send_msg
(
iotask
,
I
nteraction
(
cb
));
}
/**
...
...
@@ -74,20 +74,20 @@ unsafe fn interact(iotask: iotask,
* async handle and do a sanity check to make sure that all other handles are
* closed, causing a failure otherwise.
*/
fn
exit
(
iotask
:
iot
ask
)
unsafe
{
send_msg
(
iotask
,
teardown_l
oop
);
fn
exit
(
iotask
:
IoT
ask
)
unsafe
{
send_msg
(
iotask
,
TeardownL
oop
);
}
// INTERNAL API
enum
iotask_m
sg
{
i
nteraction
(
fn
~
(
*
libc
::
c_void
)),
teardown_l
oop
enum
IoTaskM
sg
{
I
nteraction
(
fn
~
(
*
libc
::
c_void
)),
TeardownL
oop
}
/// Run the loop and begin handling messages
fn
run_loop
(
iotask_ch
:
Chan
<
iot
ask
>
)
unsafe
{
fn
run_loop
(
iotask_ch
:
Chan
<
IoT
ask
>
)
unsafe
{
let
loop_ptr
=
ll
::
loop_new
();
...
...
@@ -100,7 +100,7 @@ fn run_loop(iotask_ch: Chan<iotask>) unsafe {
ll
::
async_init
(
loop_ptr
,
async_handle
,
wake_up_cb
);
// initialize our loop data and store it in the loop
let
data
:
iotask_loop_d
ata
=
{
let
data
:
IoTaskLoopD
ata
=
{
async_handle
:
async_handle
,
msg_po
:
Port
()
};
...
...
@@ -108,7 +108,7 @@ fn run_loop(iotask_ch: Chan<iotask>) unsafe {
// Send out a handle through which folks can talk to us
// while we dwell in the I/O loop
let
iotask
=
iot
ask_
({
let
iotask
=
IoT
ask_
({
async_handle
:
async_handle
,
op_chan
:
data
.msg_po
.chan
()
});
...
...
@@ -122,13 +122,13 @@ fn run_loop(iotask_ch: Chan<iotask>) unsafe {
}
// data that lives for the lifetime of the high-evel oo
type
iotask_loop_d
ata
=
{
type
IoTaskLoopD
ata
=
{
async_handle
:
*
ll
::
uv_async_t
,
msg_po
:
Port
<
iotask_m
sg
>
msg_po
:
Port
<
IoTaskM
sg
>
};
fn
send_msg
(
iotask
:
iot
ask
,
-
msg
:
iotask_m
sg
)
unsafe
{
fn
send_msg
(
iotask
:
IoT
ask
,
-
msg
:
IoTaskM
sg
)
unsafe
{
iotask
.op_chan
.send
(
msg
);
ll
::
async_send
(
iotask
.async_handle
);
}
...
...
@@ -141,18 +141,18 @@ fn send_msg(iotask: iotask,
async_handle
,
status
));
let
loop_ptr
=
ll
::
get_loop_for_uv_handle
(
async_handle
);
let
data
=
ll
::
get_data_for_uv_handle
(
async_handle
)
as
*
iotask_loop_d
ata
;
let
data
=
ll
::
get_data_for_uv_handle
(
async_handle
)
as
*
IoTaskLoopD
ata
;
let
msg_po
=
(
*
data
)
.msg_po
;
while
msg_po
.peek
()
{
match
msg_po
.recv
()
{
i
nteraction
(
cb
)
=>
cb
(
loop_ptr
),
teardown_l
oop
=>
begin_teardown
(
data
)
I
nteraction
(
cb
)
=>
cb
(
loop_ptr
),
TeardownL
oop
=>
begin_teardown
(
data
)
}
}
}
fn
begin_teardown
(
data
:
*
iotask_loop_d
ata
)
unsafe
{
fn
begin_teardown
(
data
:
*
IoTaskLoopD
ata
)
unsafe
{
log
(
debug
,
~
"iotask begin_teardown() called, close async_handle"
);
let
async_handle
=
(
*
data
)
.async_handle
;
ll
::
close
(
async_handle
as
*
c_void
,
tear_down_close_cb
);
...
...
@@ -171,7 +171,7 @@ mod test {
extern
fn
async_close_cb
(
handle
:
*
ll
::
uv_async_t
)
unsafe
{
log
(
debug
,
fmt!
(
"async_close_cb handle %?"
,
handle
));
let
exit_ch
=
(
*
(
ll
::
get_data_for_uv_handle
(
handle
)
as
*
ah_d
ata
))
.exit_ch
;
as
*
AhD
ata
))
.exit_ch
;
core
::
comm
::
send
(
exit_ch
,
());
}
extern
fn
async_handle_cb
(
handle
:
*
ll
::
uv_async_t
,
status
:
libc
::
c_int
)
...
...
@@ -179,11 +179,11 @@ mod test {
log
(
debug
,
fmt!
(
"async_handle_cb handle %? status %?"
,
handle
,
status
));
ll
::
close
(
handle
,
async_close_cb
);
}
type
ah_d
ata
=
{
iotask
:
iot
ask
,
type
AhD
ata
=
{
iotask
:
IoT
ask
,
exit_ch
:
comm
::
Chan
<
()
>
};
fn
impl_uv_iotask_async
(
iotask
:
iot
ask
)
unsafe
{
fn
impl_uv_iotask_async
(
iotask
:
IoT
ask
)
unsafe
{
let
async_handle
=
ll
::
async_t
();
let
ah_ptr
=
ptr
::
addr_of
(
async_handle
);
let
exit_po
=
core
::
comm
::
Port
::
<
()
>
();
...
...
@@ -203,8 +203,8 @@ fn impl_uv_iotask_async(iotask: iotask) unsafe {
// this fn documents the bear minimum neccesary to roll your own
// high_level_loop
unsafe
fn
spawn_test_loop
(
exit_ch
:
comm
::
Chan
<
()
>
)
->
iot
ask
{
let
iotask_port
=
comm
::
Port
::
<
iot
ask
>
();
unsafe
fn
spawn_test_loop
(
exit_ch
:
comm
::
Chan
<
()
>
)
->
IoT
ask
{
let
iotask_port
=
comm
::
Port
::
<
IoT
ask
>
();
let
iotask_ch
=
comm
::
Chan
(
iotask_port
);
do
task
::
spawn_sched
(
task
::
ManualThreads
(
1u
))
{
run_loop
(
iotask_ch
);
...
...
src/libstd/uv_ll.rs
浏览文件 @
94720fce
...
...
@@ -20,6 +20,8 @@
* with per-platform, generated source files from rust-bindgen.
*/
#[allow(non_camel_case_types)]
// C types
import
libc
::
size_t
;
import
comm
=
core
::
comm
;
import
ptr
::
to_unsafe_ptr
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录