Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
2f99fb8e
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,发现更多精彩内容 >>
提交
2f99fb8e
编写于
5月 19, 2013
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core::rt: Remove local_sched module
上级
06f1a64b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
20 addition
and
53 deletion
+20
-53
src/libcore/rt/comm.rs
src/libcore/rt/comm.rs
+0
-1
src/libcore/rt/io/net/tcp.rs
src/libcore/rt/io/net/tcp.rs
+1
-1
src/libcore/rt/local_sched.rs
src/libcore/rt/local_sched.rs
+0
-32
src/libcore/rt/mod.rs
src/libcore/rt/mod.rs
+2
-5
src/libcore/rt/sched.rs
src/libcore/rt/sched.rs
+7
-3
src/libcore/rt/task.rs
src/libcore/rt/task.rs
+1
-1
src/libcore/rt/tube.rs
src/libcore/rt/tube.rs
+0
-2
src/libcore/rt/uv/uvio.rs
src/libcore/rt/uv/uvio.rs
+9
-8
未找到文件。
src/libcore/rt/comm.rs
浏览文件 @
2f99fb8e
...
...
@@ -22,7 +22,6 @@
use
kinds
::
Owned
;
use
rt
::
sched
::{
Scheduler
,
Coroutine
};
use
rt
::
local
::
Local
;
use
rt
::
local_sched
;
use
unstable
::
intrinsics
::{
atomic_xchg
,
atomic_load
};
use
util
::
Void
;
use
comm
::{
GenericChan
,
GenericSmartChan
,
GenericPort
,
Peekable
};
...
...
src/libcore/rt/io/net/tcp.rs
浏览文件 @
2f99fb8e
...
...
@@ -10,7 +10,7 @@
use
option
::{
Option
,
Some
,
None
};
use
result
::{
Ok
,
Err
};
use
rt
::
sched
::
local_sched
::
unsafe_borrow_io
;
use
rt
::
sched
::
unsafe_borrow_io
;
use
rt
::
io
::
net
::
ip
::
IpAddr
;
use
rt
::
io
::{
Reader
,
Writer
,
Listener
};
use
rt
::
io
::{
io_error
,
read_error
,
EndOfFile
};
...
...
src/libcore/rt/local_sched.rs
已删除
100644 → 0
浏览文件 @
06f1a64b
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Access to the thread-local Scheduler
use
prelude
::
*
;
use
ptr
::
mut_null
;
use
libc
::
c_void
;
use
cast
;
use
cell
::
Cell
;
use
rt
::
sched
::
Scheduler
;
use
rt
::
rtio
::{
EventLoop
,
IoFactoryObject
};
use
unstable
::
finally
::
Finally
;
use
rt
::
local_ptr
;
use
tls
=
rt
::
thread_local_storage
;
use
rt
::
local
::
Local
;
#[cfg(test)]
use
rt
::
uv
::
uvio
::
UvEventLoop
;
pub
unsafe
fn
unsafe_borrow_io
()
->
*
mut
IoFactoryObject
{
let
sched
=
Local
::
unsafe_borrow
::
<
Scheduler
>
();
let
io
:
*
mut
IoFactoryObject
=
(
*
sched
)
.event_loop
.io
()
.unwrap
();
return
io
;
}
src/libcore/rt/mod.rs
浏览文件 @
2f99fb8e
...
...
@@ -67,9 +67,6 @@
/// The coroutine task scheduler, built on the `io` event loop.
mod
sched
;
/// Thread-local access to the current Scheduler.
pub
mod
local_sched
;
/// Synchronous I/O.
#[path
=
"io/mod.rs"
]
pub
mod
io
;
...
...
@@ -189,7 +186,7 @@ pub fn context() -> RuntimeContext {
use
task
::
rt
::
rust_task
;
use
self
::
local
::
Local
;
use
self
::
sched
::
{
local_sched
,
Scheduler
}
;
use
self
::
sched
::
Scheduler
;
// XXX: Hitting TLS twice to check if the scheduler exists
// then to check for the task is not good for perf
...
...
@@ -220,7 +217,7 @@ pub fn context() -> RuntimeContext {
#[test]
fn
test_context
()
{
use
unstable
::
run_in_bare_thread
;
use
self
::
sched
::{
local_sched
,
Scheduler
,
Coroutine
};
use
self
::
sched
::{
Scheduler
,
Coroutine
};
use
rt
::
uv
::
uvio
::
UvEventLoop
;
use
cell
::
Cell
;
use
rt
::
local
::
Local
;
...
...
src/libcore/rt/sched.rs
浏览文件 @
2f99fb8e
...
...
@@ -20,9 +20,7 @@
use
super
::
task
::
Task
;
use
rt
::
local_ptr
;
use
rt
::
local
::
Local
;
// A more convenient name for external callers, e.g. `local_sched::take()`
pub
mod
local_sched
;
use
rt
::
rtio
::
IoFactoryObject
;
/// The Scheduler is responsible for coordinating execution of Coroutines
/// on a single thread. When the scheduler is running it is owned by
...
...
@@ -403,6 +401,12 @@ fn recycle(~self, stack_pool: &mut StackPool) {
}
}
pub
unsafe
fn
unsafe_borrow_io
()
->
*
mut
IoFactoryObject
{
let
sched
=
Local
::
unsafe_borrow
::
<
Scheduler
>
();
let
io
:
*
mut
IoFactoryObject
=
(
*
sched
)
.event_loop
.io
()
.unwrap
();
return
io
;
}
#[cfg(test)]
mod
test
{
use
int
;
...
...
src/libcore/rt/task.rs
浏览文件 @
2f99fb8e
...
...
@@ -16,7 +16,7 @@
use
prelude
::
*
;
use
libc
::{
c_void
,
uintptr_t
};
use
cast
::
transmute
;
use
super
::
sched
::
{
Scheduler
,
local_sched
}
;
use
super
::
sched
::
Scheduler
;
use
rt
::
local
::
Local
;
use
super
::
local_heap
::
LocalHeap
;
use
rt
::
logging
::
StdErrLogger
;
...
...
src/libcore/rt/tube.rs
浏览文件 @
2f99fb8e
...
...
@@ -18,7 +18,6 @@
use
super
::
rc
::
RC
;
use
rt
::
sched
::{
Scheduler
,
Coroutine
};
use
rt
::{
context
,
TaskContext
,
SchedulerContext
};
use
rt
::
local_sched
;
use
rt
::
local
::
Local
;
use
vec
::
OwnedVector
;
use
container
::
Container
;
...
...
@@ -95,7 +94,6 @@ fn clone(&self) -> Tube<T> {
mod
test
{
use
int
;
use
cell
::
Cell
;
use
rt
::
local_sched
;
use
rt
::
test
::
*
;
use
rt
::
rtio
::
EventLoop
;
use
rt
::
sched
::
Scheduler
;
...
...
src/libcore/rt/uv/uvio.rs
浏览文件 @
2f99fb8e
...
...
@@ -19,7 +19,8 @@
use
rt
::
uv
::
*
;
use
rt
::
uv
::
idle
::
IdleWatcher
;
use
rt
::
rtio
::
*
;
use
rt
::
sched
::{
Scheduler
,
local_sched
};
use
rt
::
sched
::
unsafe_borrow_io
;
use
rt
::
sched
::
Scheduler
;
use
rt
::
io
::{
standard_error
,
OtherIoError
};
use
rt
::
tube
::
Tube
;
use
rt
::
local
::
Local
;
...
...
@@ -358,7 +359,7 @@ fn write(&mut self, buf: &[u8]) -> Result<(), IoError> {
fn
test_simple_io_no_connect
()
{
do
run_in_newsched_task
{
unsafe
{
let
io
=
local_sched
::
unsafe_borrow_io
();
let
io
=
unsafe_borrow_io
();
let
addr
=
next_test_ip4
();
let
maybe_chan
=
(
*
io
)
.tcp_connect
(
addr
);
assert
!
(
maybe_chan
.is_err
());
...
...
@@ -374,7 +375,7 @@ fn test_simple_tcp_server_and_client() {
// Start the server first so it's listening when we connect
do
spawntask_immediately
{
unsafe
{
let
io
=
local_sched
::
unsafe_borrow_io
();
let
io
=
unsafe_borrow_io
();
let
mut
listener
=
(
*
io
)
.tcp_bind
(
addr
)
.unwrap
();
let
mut
stream
=
listener
.accept
()
.unwrap
();
let
mut
buf
=
[
0
,
..
2048
];
...
...
@@ -389,7 +390,7 @@ fn test_simple_tcp_server_and_client() {
do
spawntask_immediately
{
unsafe
{
let
io
=
local_sched
::
unsafe_borrow_io
();
let
io
=
unsafe_borrow_io
();
let
mut
stream
=
(
*
io
)
.tcp_connect
(
addr
)
.unwrap
();
stream
.write
([
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
]);
}
...
...
@@ -403,7 +404,7 @@ fn test_read_and_block() {
let
addr
=
next_test_ip4
();
do
spawntask_immediately
{
let
io
=
unsafe
{
local_sched
::
unsafe_borrow_io
()
};
let
io
=
unsafe
{
unsafe_borrow_io
()
};
let
mut
listener
=
unsafe
{
(
*
io
)
.tcp_bind
(
addr
)
.unwrap
()
};
let
mut
stream
=
listener
.accept
()
.unwrap
();
let
mut
buf
=
[
0
,
..
2048
];
...
...
@@ -439,7 +440,7 @@ fn test_read_and_block() {
do
spawntask_immediately
{
unsafe
{
let
io
=
local_sched
::
unsafe_borrow_io
();
let
io
=
unsafe_borrow_io
();
let
mut
stream
=
(
*
io
)
.tcp_connect
(
addr
)
.unwrap
();
stream
.write
([
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
]);
stream
.write
([
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
]);
...
...
@@ -459,7 +460,7 @@ fn test_read_read_read() {
do
spawntask_immediately
{
unsafe
{
let
io
=
local_sched
::
unsafe_borrow_io
();
let
io
=
unsafe_borrow_io
();
let
mut
listener
=
(
*
io
)
.tcp_bind
(
addr
)
.unwrap
();
let
mut
stream
=
listener
.accept
()
.unwrap
();
let
buf
=
[
1
,
..
2048
];
...
...
@@ -473,7 +474,7 @@ fn test_read_read_read() {
do
spawntask_immediately
{
unsafe
{
let
io
=
local_sched
::
unsafe_borrow_io
();
let
io
=
unsafe_borrow_io
();
let
mut
stream
=
(
*
io
)
.tcp_connect
(
addr
)
.unwrap
();
let
mut
buf
=
[
0
,
..
2048
];
let
mut
total_bytes_read
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录