Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
af60cf40
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,发现更多精彩内容 >>
提交
af60cf40
编写于
10月 04, 2011
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rt: Switch the AIO stuff to the C stack
上级
6335529c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
19 deletion
+17
-19
src/lib/aio.rs
src/lib/aio.rs
+1
-1
src/rt/rust_uv.cpp
src/rt/rust_uv.cpp
+16
-18
未找到文件。
src/lib/aio.rs
浏览文件 @
af60cf40
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
import
comm
::{
chan
,
port
,
send
,
recv
};
import
comm
::{
chan
,
port
,
send
,
recv
};
import
net
;
import
net
;
native
"
rust
"
mod
rustrt
{
native
"
c-stack-cdecl
"
mod
rustrt
{
type
socket
;
type
socket
;
type
server
;
type
server
;
fn
aio_init
();
fn
aio_init
();
...
...
src/rt/rust_uv.cpp
浏览文件 @
af60cf40
...
@@ -50,7 +50,7 @@ struct socket_data : public task_owned<socket_data> {
...
@@ -50,7 +50,7 @@ struct socket_data : public task_owned<socket_data> {
struct
req_connect
:
public
uv_connect_t
,
public
task_owned
<
req_connect
>
{};
struct
req_connect
:
public
uv_connect_t
,
public
task_owned
<
req_connect
>
{};
struct
req_write
:
public
uv_write_t
,
public
task_owned
<
req_write
>
{};
struct
req_write
:
public
uv_write_t
,
public
task_owned
<
req_write
>
{};
extern
"C"
CDECL
void
aio_close_socket
(
void
*
,
socket_data
*
);
extern
"C"
CDECL
void
aio_close_socket
(
socket_data
*
);
static
uv_idle_s
idle_handler
;
static
uv_idle_s
idle_handler
;
...
@@ -59,7 +59,7 @@ static void idle_callback(uv_idle_t* handle, int status) {
...
@@ -59,7 +59,7 @@ static void idle_callback(uv_idle_t* handle, int status) {
task
->
yield
();
task
->
yield
();
}
}
extern
"C"
CDECL
void
aio_init
(
void
*
)
{
extern
"C"
CDECL
void
aio_init
()
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
iotask
=
task
;
iotask
=
task
;
...
@@ -67,7 +67,7 @@ extern "C" CDECL void aio_init(void *) {
...
@@ -67,7 +67,7 @@ extern "C" CDECL void aio_init(void *) {
uv_idle_start
(
&
idle_handler
,
idle_callback
);
uv_idle_start
(
&
idle_handler
,
idle_callback
);
}
}
extern
"C"
CDECL
void
aio_run
(
void
*
)
{
extern
"C"
CDECL
void
aio_run
()
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
idle_handler
.
data
=
task
;
idle_handler
.
data
=
task
;
...
@@ -76,14 +76,13 @@ extern "C" CDECL void aio_run(void *) {
...
@@ -76,14 +76,13 @@ extern "C" CDECL void aio_run(void *) {
void
nop_close
(
uv_handle_t
*
handle
)
{}
void
nop_close
(
uv_handle_t
*
handle
)
{}
extern
"C"
CDECL
void
aio_stop
(
void
*
)
{
extern
"C"
CDECL
void
aio_stop
()
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
uv_close
((
uv_handle_t
*
)
&
idle_handler
,
nop_close
);
uv_close
((
uv_handle_t
*
)
&
idle_handler
,
nop_close
);
}
}
static
socket_data
*
make_socket
(
void
*
,
rust_chan
*
chan
)
{
static
socket_data
*
make_socket
(
rust_task
*
task
,
rust_chan
*
chan
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
socket_data
*
data
=
new
(
task
,
"make_socket"
)
socket_data
;
socket_data
*
data
=
new
(
task
,
"make_socket"
)
socket_data
;
if
(
!
data
||
if
(
!
data
||
uv_tcp_init
(
uv_default_loop
(),
&
data
->
socket
))
{
uv_tcp_init
(
uv_default_loop
(),
&
data
->
socket
))
{
...
@@ -153,14 +152,14 @@ static void new_connection(uv_stream_t *socket, int status) {
...
@@ -153,14 +152,14 @@ static void new_connection(uv_stream_t *socket, int status) {
return
;
return
;
}
}
if
(
uv_accept
(
socket
,
(
uv_stream_t
*
)
&
client
->
socket
))
{
if
(
uv_accept
(
socket
,
(
uv_stream_t
*
)
&
client
->
socket
))
{
aio_close_socket
(
client
->
task
,
client
);
aio_close_socket
(
client
);
server
->
task
->
fail
();
server
->
task
->
fail
();
return
;
return
;
}
}
server
->
chan
->
send
(
&
client
);
server
->
chan
->
send
(
&
client
);
}
}
extern
"C"
CDECL
socket_data
*
aio_serve
(
void
*
,
const
char
*
ip
,
int
port
,
extern
"C"
CDECL
socket_data
*
aio_serve
(
const
char
*
ip
,
int
port
,
chan_handle
*
_chan
)
{
chan_handle
*
_chan
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
...
@@ -172,7 +171,7 @@ extern "C" CDECL socket_data *aio_serve(void *, const char *ip, int port,
...
@@ -172,7 +171,7 @@ extern "C" CDECL socket_data *aio_serve(void *, const char *ip, int port,
goto
oom
;
goto
oom
;
if
(
uv_tcp_bind
(
&
server
->
socket
,
addr
)
||
if
(
uv_tcp_bind
(
&
server
->
socket
,
addr
)
||
uv_listen
((
uv_stream_t
*
)
&
server
->
socket
,
128
,
new_connection
))
{
uv_listen
((
uv_stream_t
*
)
&
server
->
socket
,
128
,
new_connection
))
{
aio_close_socket
(
task
,
server
);
aio_close_socket
(
server
);
chan
->
deref
();
chan
->
deref
();
return
NULL
;
return
NULL
;
}
}
...
@@ -207,13 +206,13 @@ static void free_socket(uv_handle_t *handle) {
...
@@ -207,13 +206,13 @@ static void free_socket(uv_handle_t *handle) {
delete
data
;
delete
data
;
}
}
extern
"C"
CDECL
void
aio_close_socket
(
void
*
,
socket_data
*
client
)
{
extern
"C"
CDECL
void
aio_close_socket
(
socket_data
*
client
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
uv_close
((
uv_handle_t
*
)
&
client
->
socket
,
free_socket
);
uv_close
((
uv_handle_t
*
)
&
client
->
socket
,
free_socket
);
}
}
extern
"C"
CDECL
void
aio_close_server
(
void
*
,
socket_data
*
server
,
extern
"C"
CDECL
void
aio_close_server
(
socket_data
*
server
,
chan_handle
*
_chan
)
{
chan_handle
*
_chan
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
...
@@ -225,11 +224,11 @@ extern "C" CDECL void aio_close_server(void *, socket_data *server,
...
@@ -225,11 +224,11 @@ extern "C" CDECL void aio_close_server(void *, socket_data *server,
server
->
chan
->
send
(
&
null_client
);
server
->
chan
->
send
(
&
null_client
);
server
->
chan
->
deref
();
server
->
chan
->
deref
();
server
->
chan
=
chan
->
clone
(
iotask
);
server
->
chan
=
chan
->
clone
(
iotask
);
aio_close_socket
(
task
,
server
);
aio_close_socket
(
server
);
chan
->
deref
();
chan
->
deref
();
}
}
extern
"C"
CDECL
bool
aio_is_null_client
(
void
*
,
socket_data
*
server
)
{
extern
"C"
CDECL
bool
aio_is_null_client
(
socket_data
*
server
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
return
server
==
NULL
;
return
server
==
NULL
;
...
@@ -242,7 +241,7 @@ static void connection_complete(uv_connect_t *req, int status) {
...
@@ -242,7 +241,7 @@ static void connection_complete(uv_connect_t *req, int status) {
free
(
req
);
free
(
req
);
}
}
extern
"C"
CDECL
void
aio_connect
(
void
*
,
const
char
*
host
,
int
port
,
extern
"C"
CDECL
void
aio_connect
(
const
char
*
host
,
int
port
,
chan_handle
*
_chan
)
{
chan_handle
*
_chan
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
...
@@ -266,7 +265,7 @@ extern "C" CDECL void aio_connect(void *, const char *host, int port,
...
@@ -266,7 +265,7 @@ extern "C" CDECL void aio_connect(void *, const char *host, int port,
}
}
free
(
req
);
free
(
req
);
oom_req:
oom_req:
aio_close_socket
(
task
,
client
);
aio_close_socket
(
client
);
oom_client:
oom_client:
chan
->
deref
();
chan
->
deref
();
task
->
fail
();
task
->
fail
();
...
@@ -281,7 +280,7 @@ static void write_complete(uv_write_t *req, int status) {
...
@@ -281,7 +280,7 @@ static void write_complete(uv_write_t *req, int status) {
free
(
req
);
free
(
req
);
}
}
extern
"C"
CDECL
void
aio_writedata
(
void
*
,
socket_data
*
data
,
char
*
buf
,
extern
"C"
CDECL
void
aio_writedata
(
socket_data
*
data
,
char
*
buf
,
size_t
size
,
chan_handle
*
_chan
)
{
size_t
size
,
chan_handle
*
_chan
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
...
@@ -314,8 +313,7 @@ fail:
...
@@ -314,8 +313,7 @@ fail:
task
->
fail
();
task
->
fail
();
}
}
extern
"C"
CDECL
void
aio_read
(
void
*
,
socket_data
*
data
,
extern
"C"
CDECL
void
aio_read
(
socket_data
*
data
,
chan_handle
*
_chan
)
{
chan_handle
*
_chan
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
rust_chan
*
reader
=
task
->
get_chan_by_handle
(
_chan
);
rust_chan
*
reader
=
task
->
get_chan_by_handle
(
_chan
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录