diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-05-24 16:42:05 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-05-24 16:42:16 -0700 |
| commit | a8c8c8ae286b517fe00da9f68a776ce1e6845f0d (patch) | |
| tree | dd90e1a3d456b9e58abbbd0c6d2d32a5ffc68fa0 /src/libstd | |
| parent | 433e4ca5f166f2e3322b90bc53f32bc44d534640 (diff) | |
| download | rust-a8c8c8ae286b517fe00da9f68a776ce1e6845f0d.tar.gz rust-a8c8c8ae286b517fe00da9f68a776ce1e6845f0d.zip | |
std: FIXME's and cleanups for uv
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/net_tcp.rs | 14 | ||||
| -rw-r--r-- | src/libstd/timer.rs | 2 | ||||
| -rw-r--r-- | src/libstd/uv_hl.rs | 7 |
3 files changed, 20 insertions, 3 deletions
diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 97fb2de4f98..0f29b0c391e 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -2,6 +2,7 @@ High-level interface to libuv's TCP functionality "]; +// FIXME: Fewer import *'s import ip = net_ip; import comm::*; import result::*; @@ -118,11 +119,11 @@ fn connect(input_ip: ip::ip_addr, port: uint, log(debug, #fmt("tcp_connect result_ch %?", conn_data.result_ch)); // get an unsafe representation of our stream_handle_ptr that // we can send into the interact cb to be handled in libuv.. - log(debug, #fmt("stream_handl_ptr outside interact %?", + log(debug, #fmt("stream_handle_ptr outside interact %?", stream_handle_ptr)); uv::hl::interact(hl_loop) {|loop_ptr| log(debug, "in interact cb for tcp client connect.."); - log(debug, #fmt("stream_handl_ptr in interact %?", + log(debug, #fmt("stream_handle_ptr in interact %?", stream_handle_ptr)); alt uv::ll::tcp_init( loop_ptr, stream_handle_ptr) { 0i32 { @@ -191,7 +192,7 @@ fn connect(input_ip: ip::ip_addr, port: uint, } #[doc=" -Write binary data to a tcp stream; Blocks until operatoin completes +Write binary data to a tcp stream; Blocks until operation completes # Arguments @@ -360,6 +361,8 @@ fn new_listener(host_ip: ip::ip_addr, port: uint, backlog: uint, let new_conn_po = comm::port::<result::result<*uv::ll::uv_tcp_t, tcp_err_data>>(); let new_conn_ch = comm::chan(new_conn_po); + // FIXME: This shared box should not be captured in the i/o task + // Make it a unique pointer. let server_data: @tcp_conn_port_data = @{ server_stream: uv::ll::tcp_t(), stream_closed_po: stream_closed_po, @@ -940,6 +943,10 @@ fn write_common_impl(socket_data_ptr: *tcp_socket_data, } } }; + // FIXME: Instead of passing unsafe pointers to local data, and waiting + // here for the write to complete, we should transfer ownership of + // everything to the I/O task and let it deal with the aftermath, + // so we don't have to sit here blocking. alt comm::recv(result_po) { tcp_write_success { result::ok(()) } tcp_write_error(err_data) { result::err(err_data.to_tcp_err()) } @@ -1181,6 +1188,7 @@ crust fn tcp_write_complete_cb(write_req: *uv::ll::uv_write_t, status: libc::c_int) unsafe { let write_data_ptr = uv::ll::get_data_for_req(write_req) as *write_req_data; + // FIXME: if instead of alt alt status { 0i32 { log(debug, "successful write complete"); diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index f910b724c44..f6b88c810f4 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -23,6 +23,7 @@ for *at least* that period of time. "] fn delayed_send<T: copy send>(hl_loop: uv::hl::high_level_loop, msecs: uint, ch: comm::chan<T>, val: T) { + // FIME: Looks like we don't need to spawn here task::spawn() {|| unsafe { let timer_done_po = comm::port::<()>(); @@ -103,6 +104,7 @@ fn recv_timeout<T: copy send>(hl_loop: uv::hl::high_level_loop, let timeout_po = comm::port::<()>(); let timeout_ch = comm::chan(timeout_po); delayed_send(hl_loop, msecs, timeout_ch, ()); + // FIXME: This could be written clearer either::either( {|left_val| log(debug, #fmt("recv_time .. left_val %?", diff --git a/src/libstd/uv_hl.rs b/src/libstd/uv_hl.rs index 83080348d0b..a803c04c80b 100644 --- a/src/libstd/uv_hl.rs +++ b/src/libstd/uv_hl.rs @@ -11,6 +11,7 @@ export run_high_level_loop, interact; import ll = uv_ll; +// FIXME: Newtype syntax #[doc = " Used to abstract-away direct interaction with a libuv loop. "] @@ -125,8 +126,10 @@ unsafe fn interact(hl_loop: high_level_loop, // INTERNAL API +// FIXME: Newtype syntax // data that lives for the lifetime of the high-evel oo enum hl_loop_data { + // FIXME: hl, not gl? default_gl_data({ async_handle: *ll::uv_async_t, mut active: bool, @@ -135,6 +138,7 @@ enum hl_loop_data { msg_po_ptr: *comm::port<high_level_msg>}) } +// FIXME: This function can be much simpler unsafe fn send_high_level_msg(hl_loop: high_level_loop, -msg: high_level_msg) { let op_chan = alt hl_loop{simple_task_loop({async_handle, op_chan}){ @@ -164,9 +168,12 @@ crust fn high_level_wake_up_cb(async_handle: *ll::uv_async_t, 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 *hl_loop_data; + // FIXME: What is this checking? + // FIXME: Use if not alt alt (*data).active { true { let msg_po = *((*data).msg_po_ptr); + // FIXME: Convert to while loop alt comm::peek(msg_po) { true { loop { |
