diff options
| author | Marijn Haverbeke <marijnh@gmail.com> | 2011-08-25 10:18:02 +0200 |
|---|---|---|
| committer | Marijn Haverbeke <marijnh@gmail.com> | 2011-08-29 09:07:53 +0200 |
| commit | c9c5ee252a8523778377f2832765442e611e85a4 (patch) | |
| tree | 85c0837af34b2431fc17da0a166254144aaa99c7 /src/rt/rust_uv.cpp | |
| parent | 855e0a471365c7c61a139e2437215028bd231af5 (diff) | |
| download | rust-c9c5ee252a8523778377f2832765442e611e85a4.tar.gz rust-c9c5ee252a8523778377f2832765442e611e85a4.zip | |
Implement non-internal ivecs
Vectors are now similar to our old, pre-internal vectors, except that they are uniquely owned, not refcounted. Their name should probably change too, then. I've renamed them to vec in the runtime, will do so throughout the compiler later.
Diffstat (limited to 'src/rt/rust_uv.cpp')
| -rw-r--r-- | src/rt/rust_uv.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/rt/rust_uv.cpp b/src/rt/rust_uv.cpp index b792121de35..add0e8da455 100644 --- a/src/rt/rust_uv.cpp +++ b/src/rt/rust_uv.cpp @@ -113,12 +113,12 @@ static socket_data *make_socket(rust_task *task, rust_chan *chan) { static uv_buf_t alloc_buffer(uv_stream_t *socket, size_t suggested_size) { LOG_CALLBACK_ENTRY(socket); uv_buf_t buf; - size_t actual_size = suggested_size + sizeof (rust_ivec_heap); + size_t actual_size = suggested_size + sizeof (rust_vec); socket_data *data = (socket_data*)socket->data; char *base = reinterpret_cast<char*>(data->task->kernel->malloc(actual_size, "read buffer")); - buf.base = base + sizeof (rust_ivec_heap); + buf.base = base + sizeof (rust_vec); buf.len = suggested_size; return buf; } @@ -129,26 +129,23 @@ static void read_progress(uv_stream_t *socket, ssize_t nread, uv_buf_t buf) { I(data->task->sched, data->reader != NULL); I(data->task->sched, nread <= ssize_t(buf.len)); - rust_ivec_heap *base = reinterpret_cast<rust_ivec_heap*>( - reinterpret_cast<char*>(buf.base) - sizeof (rust_ivec_heap)); - rust_ivec v; - v.fill = 0; - v.alloc = buf.len; - v.payload.ptr = base; + rust_vec *v = reinterpret_cast<rust_vec*>( + reinterpret_cast<char*>(buf.base) - sizeof (rust_vec)); + v->alloc = buf.len; switch (nread) { case -1: // End of stream - base->fill = 0; + v->fill = 0; uv_read_stop(socket); break; case 0: // Nothing read - data->task->kernel->free(base); + data->task->kernel->free(v); return; default: // Got nread bytes - base->fill = nread; + v->fill = nread; break; } - data->reader->send(&v); + data->reader->send(v); } static void new_connection(uv_handle_t *socket, int status) { |
