diff options
| author | Jeff Olson <olson.jeffery@gmail.com> | 2012-02-17 16:33:56 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-02-28 17:56:14 -0800 |
| commit | ffad8d7f0cc4917f46757f5a431f6207238bf59b (patch) | |
| tree | 9886b90c1c311a31b94596e9150557bb08ac596f /src/rt/rust_uvtmp.cpp | |
| parent | 418c6bcec35a5552f8732946819f792da75bf555 (diff) | |
| download | rust-ffad8d7f0cc4917f46757f5a431f6207238bf59b.tar.gz rust-ffad8d7f0cc4917f46757f5a431f6207238bf59b.zip | |
everything is laid out and working through a basic hw
the core impl is there, with a async handle in place to take incoming operations from user code. No actual uv handle/operations are implemented yet, though.
Diffstat (limited to 'src/rt/rust_uvtmp.cpp')
| -rw-r--r-- | src/rt/rust_uvtmp.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/rt/rust_uvtmp.cpp b/src/rt/rust_uvtmp.cpp index 7bd0b4fe55b..4a8df1fa886 100644 --- a/src/rt/rust_uvtmp.cpp +++ b/src/rt/rust_uvtmp.cpp @@ -55,6 +55,58 @@ struct timer_start_data { chan_handle chan; }; +// UVTMP REWORK + +static void* +current_kernel_malloc(size_t size, const char* tag) { + return rust_task_thread::get_task()->malloc(size, tag); +} + +/* +static void +current_kernel_free(void* ptr) { + rust_task_thread::get_task()->free(ptr); +} +*/ + +extern "C" void* +rust_uvtmp_uv_loop_new() { + return (void*)uv_loop_new(); +} + +extern "C" void +rust_uvtmp_uv_loop_set_data(uv_loop_t* loop, void* data) { + loop->data = data; +} + +typedef void (*async_op_cb)(void* data); +void native_async_op_cb(uv_async_t* handle, int status) { + async_op_cb cb = (async_op_cb)handle->data; + void* loop_data = handle->loop->data; + cb(loop_data); +} + +extern "C" void* +rust_uvtmp_uv_bind_op_cb(uv_loop_t* loop, async_op_cb cb) { + uv_async_t* async = (uv_async_t*)current_kernel_malloc( + sizeof(uv_async_t), + "uv_async_t"); + uv_async_init(loop, async, native_async_op_cb); + async->data = (void*)cb; + return async; +} + +extern "C" void rust_uvtmp_uv_run(uv_loop_t* loop) { + uv_run(loop); +} + +extern "C" void +rust_uvtmp_uv_async_send(uv_async_t* handle) { + uv_async_send(handle); +} + +// UVTMP REWORK + // FIXME: Copied from rust_builtins.cpp. Could bitrot easily static void send(rust_task *task, chan_handle chan, void *data) { |
