Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
53c9b9a5
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,发现更多精彩内容 >>
提交
53c9b9a5
编写于
10月 03, 2011
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rt: Switch the libuv bindings over to not using explicit task pointers
上级
3ad4fa00
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
27 addition
and
17 deletion
+27
-17
src/rt/rust_uv.cpp
src/rt/rust_uv.cpp
+27
-17
未找到文件。
src/rt/rust_uv.cpp
浏览文件 @
53c9b9a5
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include "uv.h"
#include "uv.h"
#include "rust_internal.h"
#include "rust_internal.h"
#include "rust_scheduler.h"
#include "rust_upcall.h"
#include "rust_upcall.h"
#ifdef __GNUC__
#ifdef __GNUC__
...
@@ -49,7 +50,7 @@ struct socket_data : public task_owned<socket_data> {
...
@@ -49,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
(
rust_task
*
task
,
socket_data
*
);
extern
"C"
CDECL
void
aio_close_socket
(
void
*
,
socket_data
*
);
static
uv_idle_s
idle_handler
;
static
uv_idle_s
idle_handler
;
...
@@ -58,14 +59,16 @@ static void idle_callback(uv_idle_t* handle, int status) {
...
@@ -58,14 +59,16 @@ static void idle_callback(uv_idle_t* handle, int status) {
task
->
yield
();
task
->
yield
();
}
}
extern
"C"
CDECL
void
aio_init
(
rust_task
*
task
)
{
extern
"C"
CDECL
void
aio_init
(
void
*
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
iotask
=
task
;
iotask
=
task
;
uv_idle_init
(
uv_default_loop
(),
&
idle_handler
);
uv_idle_init
(
uv_default_loop
(),
&
idle_handler
);
uv_idle_start
(
&
idle_handler
,
idle_callback
);
uv_idle_start
(
&
idle_handler
,
idle_callback
);
}
}
extern
"C"
CDECL
void
aio_run
(
rust_task
*
task
)
{
extern
"C"
CDECL
void
aio_run
(
void
*
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
idle_handler
.
data
=
task
;
idle_handler
.
data
=
task
;
uv_run
(
uv_default_loop
());
uv_run
(
uv_default_loop
());
...
@@ -73,12 +76,14 @@ extern "C" CDECL void aio_run(rust_task *task) {
...
@@ -73,12 +76,14 @@ extern "C" CDECL void aio_run(rust_task *task) {
void
nop_close
(
uv_handle_t
*
handle
)
{}
void
nop_close
(
uv_handle_t
*
handle
)
{}
extern
"C"
CDECL
void
aio_stop
(
rust_task
*
task
)
{
extern
"C"
CDECL
void
aio_stop
(
void
*
)
{
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
(
rust_task
*
task
,
rust_chan
*
chan
)
{
static
socket_data
*
make_socket
(
void
*
,
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
))
{
...
@@ -155,8 +160,9 @@ static void new_connection(uv_stream_t *socket, int status) {
...
@@ -155,8 +160,9 @@ static void new_connection(uv_stream_t *socket, int status) {
server
->
chan
->
send
(
&
client
);
server
->
chan
->
send
(
&
client
);
}
}
extern
"C"
CDECL
socket_data
*
aio_serve
(
rust_task
*
task
,
const
char
*
ip
,
extern
"C"
CDECL
socket_data
*
aio_serve
(
void
*
,
const
char
*
ip
,
int
port
,
int
port
,
chan_handle
*
_chan
)
{
chan_handle
*
_chan
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
rust_chan
*
chan
=
task
->
get_chan_by_handle
(
_chan
);
rust_chan
*
chan
=
task
->
get_chan_by_handle
(
_chan
);
if
(
!
chan
)
return
NULL
;
if
(
!
chan
)
return
NULL
;
...
@@ -201,13 +207,15 @@ static void free_socket(uv_handle_t *handle) {
...
@@ -201,13 +207,15 @@ static void free_socket(uv_handle_t *handle) {
delete
data
;
delete
data
;
}
}
extern
"C"
CDECL
void
aio_close_socket
(
rust_task
*
task
,
socket_data
*
client
)
{
extern
"C"
CDECL
void
aio_close_socket
(
void
*
,
socket_data
*
client
)
{
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
(
rust_task
*
task
,
socket_data
*
server
,
extern
"C"
CDECL
void
aio_close_server
(
void
*
,
socket_data
*
server
,
chan_handle
*
_chan
)
{
chan_handle
*
_chan
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
rust_chan
*
chan
=
task
->
get_chan_by_handle
(
_chan
);
rust_chan
*
chan
=
task
->
get_chan_by_handle
(
_chan
);
if
(
!
chan
)
return
;
if
(
!
chan
)
return
;
...
@@ -221,8 +229,8 @@ extern "C" CDECL void aio_close_server(rust_task *task, socket_data *server,
...
@@ -221,8 +229,8 @@ extern "C" CDECL void aio_close_server(rust_task *task, socket_data *server,
chan
->
deref
();
chan
->
deref
();
}
}
extern
"C"
CDECL
bool
aio_is_null_client
(
rust_task
*
task
,
extern
"C"
CDECL
bool
aio_is_null_client
(
void
*
,
socket_data
*
server
)
{
socket_data
*
server
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
return
server
==
NULL
;
return
server
==
NULL
;
}
}
...
@@ -234,8 +242,9 @@ static void connection_complete(uv_connect_t *req, int status) {
...
@@ -234,8 +242,9 @@ static void connection_complete(uv_connect_t *req, int status) {
free
(
req
);
free
(
req
);
}
}
extern
"C"
CDECL
void
aio_connect
(
rust_task
*
task
,
const
char
*
host
,
extern
"C"
CDECL
void
aio_connect
(
void
*
,
const
char
*
host
,
int
port
,
int
port
,
chan_handle
*
_chan
)
{
chan_handle
*
_chan
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
rust_chan
*
chan
=
task
->
get_chan_by_handle
(
_chan
);
rust_chan
*
chan
=
task
->
get_chan_by_handle
(
_chan
);
uv_connect_t
*
req
=
NULL
;
uv_connect_t
*
req
=
NULL
;
...
@@ -272,9 +281,9 @@ static void write_complete(uv_write_t *req, int status) {
...
@@ -272,9 +281,9 @@ static void write_complete(uv_write_t *req, int status) {
free
(
req
);
free
(
req
);
}
}
extern
"C"
CDECL
void
aio_writedata
(
rust_task
*
task
,
socket_data
*
data
,
extern
"C"
CDECL
void
aio_writedata
(
void
*
,
socket_data
*
data
,
char
*
buf
,
char
*
buf
,
size_t
size
,
size_t
size
,
chan_handle
*
_chan
)
{
chan_handle
*
_chan
)
{
rust_task
*
task
=
rust_scheduler
::
get_task
();
LOG_UPCALL_ENTRY
(
task
);
LOG_UPCALL_ENTRY
(
task
);
rust_chan
*
chan
=
task
->
get_chan_by_handle
(
_chan
);
rust_chan
*
chan
=
task
->
get_chan_by_handle
(
_chan
);
uv_write_t
*
req
;
uv_write_t
*
req
;
...
@@ -305,8 +314,9 @@ fail:
...
@@ -305,8 +314,9 @@ fail:
task
->
fail
();
task
->
fail
();
}
}
extern
"C"
CDECL
void
aio_read
(
rust_task
*
task
,
socket_data
*
data
,
extern
"C"
CDECL
void
aio_read
(
void
*
,
socket_data
*
data
,
chan_handle
*
_chan
)
{
chan_handle
*
_chan
)
{
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
);
if
(
!
reader
)
return
;
if
(
!
reader
)
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录