提交 94720fce 编写于 作者: B Brian Anderson

std: More camel casing

上级 d8b34b2a
......@@ -2,7 +2,7 @@
import vec;
import uint;
import iotask = uv::iotask::iotask;
import iotask = uv::iotask::IoTask;
import interact = uv::iotask::interact;
import sockaddr_in = uv::ll::sockaddr_in;
......
......@@ -2,7 +2,7 @@
import ip = net_ip;
import uv::iotask;
import uv::iotask::iotask;
import uv::iotask::IoTask;
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: iotask)
iotask: IoTask)
-> 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: iotask,
iotask: IoTask,
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: iotask,
iotask: IoTask,
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: iotask,
iotask: IoTask,
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: iotask
iotask: IoTask
};
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: iotask) -> ~str {
iotask: IoTask) -> ~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: iotask) -> tcp_listen_err_data {
iotask: IoTask) -> 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: iotask) -> result::Result<~str,
iotask: IoTask) -> result::Result<~str,
tcp_connect_err_data> {
let server_ip_addr = ip::v4::parse_addr(server_ip);
......
......@@ -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
......
......@@ -5,7 +5,7 @@
import uv = uv;
import uv::iotask;
import iotask::iotask;
import iotask::IoTask;
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: iotask,
fn delayed_send<T: copy send>(iotask: IoTask,
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: iotask, msecs: uint) {
fn sleep(iotask: IoTask, 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: iotask,
fn recv_timeout<T: copy send>(iotask: IoTask,
msecs: uint,
wait_po: comm::Port<T>) -> Option<T> {
let timeout_po = comm::Port::<()>();
......
......@@ -5,7 +5,7 @@
import ll = uv_ll;
import iotask = uv_iotask;
import get_gl = get;
import iotask::{iotask, spawn_iotask};
import iotask::{IoTask, 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() -> iotask {
fn get() -> IoTask {
return get_monitor_task_gl();
}
#[doc(hidden)]
fn get_monitor_task_gl() -> iotask unsafe {
fn get_monitor_task_gl() -> IoTask 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<iotask>;
type MonChan = Chan<IoTask>;
let monitor_ch =
do chan_from_global_ptr::<monchan>(monitor_loop_chan_ptr,
do chan_from_global_ptr::<MonChan>(monitor_loop_chan_ptr,
|| {
task::task().sched_mode
(task::SingleThreaded)
......@@ -85,7 +85,7 @@ fn get_monitor_task_gl() -> iotask unsafe {
}
}
fn spawn_loop() -> iotask {
fn spawn_loop() -> IoTask {
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: iotask) unsafe {
fn impl_uv_hl_simple_timer(iotask: IoTask) 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);
......
......@@ -5,7 +5,7 @@
* `interact` function you can execute code in a uv callback.
*/
export iotask;
export IoTask;
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 iotask {
iotask_({
enum IoTask {
IoTask_({
async_handle: *ll::uv_async_t,
op_chan: Chan<iotask_msg>
op_chan: Chan<IoTaskMsg>
})
}
fn spawn_iotask(-task: task::TaskBuilder) -> iotask {
fn spawn_iotask(-task: task::TaskBuilder) -> IoTask {
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: iotask,
unsafe fn interact(iotask: IoTask,
-cb: fn~(*c_void)) {
send_msg(iotask, interaction(cb));
send_msg(iotask, Interaction(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: iotask) unsafe {
send_msg(iotask, teardown_loop);
fn exit(iotask: IoTask) unsafe {
send_msg(iotask, TeardownLoop);
}
// INTERNAL API
enum iotask_msg {
interaction (fn~(*libc::c_void)),
teardown_loop
enum IoTaskMsg {
Interaction (fn~(*libc::c_void)),
TeardownLoop
}
/// Run the loop and begin handling messages
fn run_loop(iotask_ch: Chan<iotask>) unsafe {
fn run_loop(iotask_ch: Chan<IoTask>) 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_data = {
let data: IoTaskLoopData = {
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 = iotask_({
let iotask = IoTask_({
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_data = {
type IoTaskLoopData = {
async_handle: *ll::uv_async_t,
msg_po: Port<iotask_msg>
msg_po: Port<IoTaskMsg>
};
fn send_msg(iotask: iotask,
-msg: iotask_msg) unsafe {
fn send_msg(iotask: IoTask,
-msg: IoTaskMsg) 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_data;
let data = ll::get_data_for_uv_handle(async_handle) as *IoTaskLoopData;
let msg_po = (*data).msg_po;
while msg_po.peek() {
match msg_po.recv() {
interaction(cb) => cb(loop_ptr),
teardown_loop => begin_teardown(data)
Interaction(cb) => cb(loop_ptr),
TeardownLoop => begin_teardown(data)
}
}
}
fn begin_teardown(data: *iotask_loop_data) unsafe {
fn begin_teardown(data: *IoTaskLoopData) 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_data)).exit_ch;
as *AhData)).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_data = {
iotask: iotask,
type AhData = {
iotask: IoTask,
exit_ch: comm::Chan<()>
};
fn impl_uv_iotask_async(iotask: iotask) unsafe {
fn impl_uv_iotask_async(iotask: IoTask) 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<()>) -> iotask {
let iotask_port = comm::Port::<iotask>();
unsafe fn spawn_test_loop(exit_ch: comm::Chan<()>) -> IoTask {
let iotask_port = comm::Port::<IoTask>();
let iotask_ch = comm::Chan(iotask_port);
do task::spawn_sched(task::ManualThreads(1u)) {
run_loop(iotask_ch);
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册