Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8d00603d
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,发现更多精彩内容 >>
提交
8d00603d
编写于
8月 24, 2012
作者:
B
Ben Blum
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use less move_it in pipes and future (all but one use)
上级
6cf2f894
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
28 deletion
+16
-28
src/libcore/future.rs
src/libcore/future.rs
+7
-11
src/libcore/pipes.rs
src/libcore/pipes.rs
+9
-17
未找到文件。
src/libcore/future.rs
浏览文件 @
8d00603d
...
...
@@ -64,17 +64,13 @@ fn from_value<A>(+val: A) -> Future<A> {
})
}
macro_rules!
move_it
(
(
$x:expr
)
=>
{
unsafe
{
let
y
<-
*
ptr
::
addr_of
(
$x
);
y
}
}
)
fn
from_port
<
A
:
send
>
(
+
port
:
future_pipe
::
client
::
waiting
<
A
>
)
->
Future
<
A
>
{
#[doc
=
"
Create a future from a port
The first time that the value is requested the task will block
waiting for the result to be received on the port.
"
]
;
/*!
*
Create a future from a port
*
*
The first time that the value is requested the task will block
*
waiting for the result to be received on the port.
*/
let
port
=
~
mut
some
(
port
);
do
from_fn
|
move
port
|
{
...
...
@@ -82,7 +78,7 @@ fn from_port<A:send>(+port: future_pipe::client::waiting<A>) -> Future<A> {
port_
<->
*
port
;
let
port
=
option
::
unwrap
(
port_
);
match
recv
(
port
)
{
future_pipe
::
completed
(
data
)
=>
move_it!
(
data
)
future_pipe
::
completed
(
move
data
)
=>
data
}
}
}
...
...
src/libcore/pipes.rs
浏览文件 @
8d00603d
...
...
@@ -325,6 +325,7 @@ unsafe fn get_buffer<T: send>(p: *packet_header) -> ~buffer<T> {
transmute
((
*
p
)
.buf_header
())
}
// This could probably be done with SharedMutableState to avoid move_it!().
struct
buffer_resource
<
T
:
send
>
{
let
buffer
:
~
buffer
<
T
>
;
new
(
+
b
:
~
buffer
<
T
>
)
{
...
...
@@ -962,8 +963,8 @@ fn try_send(+x: T) -> bool {
let
mut
endp
=
none
;
endp
<->
self
.endp
;
match
move
streamp
::
client
::
try_data
(
unwrap
(
endp
),
x
)
{
some
(
next
)
=>
{
self
.endp
=
some
(
move_it!
(
next
)
);
some
(
move
next
)
=>
{
self
.endp
=
some
(
next
);
true
}
none
=>
false
...
...
@@ -984,9 +985,9 @@ fn try_recv() -> option<T> {
let
mut
endp
=
none
;
endp
<->
self
.endp
;
match
move
pipes
::
try_recv
(
unwrap
(
endp
))
{
some
(
streamp
::
data
(
x
,
endp
))
=>
{
self
.endp
=
some
(
move_it!
(
endp
)
);
some
(
move_it!
(
x
)
)
some
(
streamp
::
data
(
move
x
,
move
endp
))
=>
{
self
.endp
=
some
(
endp
);
some
(
x
)
}
none
=>
none
}
...
...
@@ -1029,12 +1030,8 @@ fn try_recv() -> option<T> {
while
result
==
none
&&
ports
.len
()
>
0
{
let
i
=
wait_many
(
ports
);
match
move
ports
[
i
]
.try_recv
()
{
// FIXME (#2329): use this version once move from enum works.
//some(copy m) => {
// result = some(move m);
//}
some
(
m
)
=>
{
result
=
some
(
move_it!
(
m
));
some
(
move
m
)
=>
{
result
=
some
(
m
);
}
none
=>
{
// Remove this port.
...
...
@@ -1047,12 +1044,7 @@ fn try_recv() -> option<T> {
}
fn
recv
()
->
T
{
match
move
self
.try_recv
()
{
// FIXME (#2329): use this version once move from enum works.
//some(copy x) => move x,
some
(
x
)
=>
move_it!
(
x
),
none
=>
fail
~
"port_set: endpoints closed"
}
option
::
unwrap_expect
(
self
.try_recv
(),
"port_set: endpoints closed"
)
}
pure
fn
peek
()
->
bool
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录