Skip to content

Commit a8c8c8a

Browse files
committed
std: FIXME's and cleanups for uv
1 parent 433e4ca commit a8c8c8a

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/libstd/net_tcp.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
High-level interface to libuv's TCP functionality
33
"];
44

5+
// FIXME: Fewer import *'s
56
import ip = net_ip;
67
import comm::*;
78
import result::*;
@@ -118,11 +119,11 @@ fn connect(input_ip: ip::ip_addr, port: uint,
118119
log(debug, #fmt("tcp_connect result_ch %?", conn_data.result_ch));
119120
// get an unsafe representation of our stream_handle_ptr that
120121
// we can send into the interact cb to be handled in libuv..
121-
log(debug, #fmt("stream_handl_ptr outside interact %?",
122+
log(debug, #fmt("stream_handle_ptr outside interact %?",
122123
stream_handle_ptr));
123124
uv::hl::interact(hl_loop) {|loop_ptr|
124125
log(debug, "in interact cb for tcp client connect..");
125-
log(debug, #fmt("stream_handl_ptr in interact %?",
126+
log(debug, #fmt("stream_handle_ptr in interact %?",
126127
stream_handle_ptr));
127128
alt uv::ll::tcp_init( loop_ptr, stream_handle_ptr) {
128129
0i32 {
@@ -191,7 +192,7 @@ fn connect(input_ip: ip::ip_addr, port: uint,
191192
}
192193

193194
#[doc="
194-
Write binary data to a tcp stream; Blocks until operatoin completes
195+
Write binary data to a tcp stream; Blocks until operation completes
195196
196197
# Arguments
197198
@@ -360,6 +361,8 @@ fn new_listener(host_ip: ip::ip_addr, port: uint, backlog: uint,
360361
let new_conn_po = comm::port::<result::result<*uv::ll::uv_tcp_t,
361362
tcp_err_data>>();
362363
let new_conn_ch = comm::chan(new_conn_po);
364+
// FIXME: This shared box should not be captured in the i/o task
365+
// Make it a unique pointer.
363366
let server_data: @tcp_conn_port_data = @{
364367
server_stream: uv::ll::tcp_t(),
365368
stream_closed_po: stream_closed_po,
@@ -940,6 +943,10 @@ fn write_common_impl(socket_data_ptr: *tcp_socket_data,
940943
}
941944
}
942945
};
946+
// FIXME: Instead of passing unsafe pointers to local data, and waiting
947+
// here for the write to complete, we should transfer ownership of
948+
// everything to the I/O task and let it deal with the aftermath,
949+
// so we don't have to sit here blocking.
943950
alt comm::recv(result_po) {
944951
tcp_write_success { result::ok(()) }
945952
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,
11811188
status: libc::c_int) unsafe {
11821189
let write_data_ptr = uv::ll::get_data_for_req(write_req)
11831190
as *write_req_data;
1191+
// FIXME: if instead of alt
11841192
alt status {
11851193
0i32 {
11861194
log(debug, "successful write complete");

src/libstd/timer.rs

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ for *at least* that period of time.
2323
"]
2424
fn delayed_send<T: copy send>(hl_loop: uv::hl::high_level_loop,
2525
msecs: uint, ch: comm::chan<T>, val: T) {
26+
// FIME: Looks like we don't need to spawn here
2627
task::spawn() {||
2728
unsafe {
2829
let timer_done_po = comm::port::<()>();
@@ -103,6 +104,7 @@ fn recv_timeout<T: copy send>(hl_loop: uv::hl::high_level_loop,
103104
let timeout_po = comm::port::<()>();
104105
let timeout_ch = comm::chan(timeout_po);
105106
delayed_send(hl_loop, msecs, timeout_ch, ());
107+
// FIXME: This could be written clearer
106108
either::either(
107109
{|left_val|
108110
log(debug, #fmt("recv_time .. left_val %?",

src/libstd/uv_hl.rs

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export run_high_level_loop, interact;
1111

1212
import ll = uv_ll;
1313

14+
// FIXME: Newtype syntax
1415
#[doc = "
1516
Used to abstract-away direct interaction with a libuv loop.
1617
"]
@@ -125,8 +126,10 @@ unsafe fn interact(hl_loop: high_level_loop,
125126

126127
// INTERNAL API
127128

129+
// FIXME: Newtype syntax
128130
// data that lives for the lifetime of the high-evel oo
129131
enum hl_loop_data {
132+
// FIXME: hl, not gl?
130133
default_gl_data({
131134
async_handle: *ll::uv_async_t,
132135
mut active: bool,
@@ -135,6 +138,7 @@ enum hl_loop_data {
135138
msg_po_ptr: *comm::port<high_level_msg>})
136139
}
137140

141+
// FIXME: This function can be much simpler
138142
unsafe fn send_high_level_msg(hl_loop: high_level_loop,
139143
-msg: high_level_msg) {
140144
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,
164168
async_handle, status));
165169
let loop_ptr = ll::get_loop_for_uv_handle(async_handle);
166170
let data = ll::get_data_for_uv_handle(async_handle) as *hl_loop_data;
171+
// FIXME: What is this checking?
172+
// FIXME: Use if not alt
167173
alt (*data).active {
168174
true {
169175
let msg_po = *((*data).msg_po_ptr);
176+
// FIXME: Convert to while loop
170177
alt comm::peek(msg_po) {
171178
true {
172179
loop {

0 commit comments

Comments
 (0)