diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 9458aca8db4d69030e22e63403ccef3055e633b6..67b4048240232bd965d25b2599f7e2b75f37fe3f 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -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; diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 1cc5fa680d2ab3e9ca3ddc2994f31290a40dff73..c7a5f90a857a042c7cc24ab3fca3df8e062da772 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -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 unsafe { let result_po = core::comm::Port::(); 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>), +new_connect_cb: fn~(tcp_new_connection, comm::Chan>)) @@ -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>), -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>, 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: &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); diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 7af5d68d648053cd1dbf3a8dc59135d7a1243864..765aff74197d6765aa52297a8750a6b652d991ff 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -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 diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index a30e28f6953d2759e62d5fd6a76b6c376bd5fec2..ff0130b77839cae91e1578cc8e75aef0d58759ba 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -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(iotask: iotask, +fn delayed_send(iotask: IoTask, msecs: uint, ch: comm::Chan, +val: T) { unsafe { let timer_done_po = core::comm::Port::<()>(); @@ -75,7 +75,7 @@ fn delayed_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(iotask: iotask, +fn recv_timeout(iotask: IoTask, msecs: uint, wait_po: comm::Port) -> Option { let timeout_po = comm::Port::<()>(); diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 29a4749b89c07c0ea67eb92604c1731880423cdc..4fec4dda4398639367febe2bc5dc779465c988df 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -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; + type MonChan = Chan; let monitor_ch = - do chan_from_global_ptr::(monitor_loop_chan_ptr, + do chan_from_global_ptr::(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::(); let exit_ch = core::comm::Chan(exit_po); let exit_ch_ptr = ptr::addr_of(exit_ch); diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 4567decf4791804670b50001adb051111ac4c1d4..42cc2e1cb609bdbda5160ae4fea3c9ba0d695367 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -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 + op_chan: Chan }) } -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) unsafe { +fn run_loop(iotask_ch: Chan) unsafe { let loop_ptr = ll::loop_new(); @@ -100,7 +100,7 @@ fn run_loop(iotask_ch: Chan) 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) 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) 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 + msg_po: Port }; -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::(); + unsafe fn spawn_test_loop(exit_ch: comm::Chan<()>) -> IoTask { + let iotask_port = comm::Port::(); let iotask_ch = comm::Chan(iotask_port); do task::spawn_sched(task::ManualThreads(1u)) { run_loop(iotask_ch); diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index aed7c316770569eb84c3ecdd84e8fcf26b0041e8..589c36f4344563259615c4271e3ccde15dea456a 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -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;