diff options
| author | bors <bors@rust-lang.org> | 2013-08-27 21:55:42 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-08-27 21:55:42 -0700 |
| commit | b8d1fa399402c71331aefd634d710004e00b73a6 (patch) | |
| tree | 575c040a4b277c8ff0107fdf673ef5a516eaf866 /src/rt/rust_uv.cpp | |
| parent | f22b4b169854c8a4ba86c16ee43327d6bcf94562 (diff) | |
| parent | 4635644746034bd01306159cc952cbdda23b3703 (diff) | |
| download | rust-b8d1fa399402c71331aefd634d710004e00b73a6.tar.gz rust-b8d1fa399402c71331aefd634d710004e00b73a6.zip | |
auto merge of #8645 : alexcrichton/rust/issue-6436-run-non-blocking, r=brson
This overhauls `std::run` to instead run on top of libuv. This is *not* in a mergeable state, I've been attempting to diagnose failures in the compiletest suite. I've managed to find a fair number of bugs so far, but I still don't seem to be done yet. Notable changes: * This requires upgrading libuv. From the discussion on #6567, I took libuv master from a few days ago, applied one patch to fix process spawning with multiple event loops in libuv, and pushed to my own fork * The build system for libuv has changed since we last used it. There's some extra checkout from a google build system which apparently does all the magic if you don't want to require autotools, and the google system just requires python. I updated the Makefile to get this build system and build libuv with it instead. This is untested on windows and arm, and both will probably need to see some improvement. * This required adding some pipe bindings to libuv as well. Currently the support is pretty simple and probably completely unsafe for pipes, but you at least get read/write methods. This is necessary for capturing output of processes. * I didn't redesign `std::run` at all, I simply tried to reimplement all the existing functionality on top of libuv. Some functions ended up dying, but nothing major. All uses of `std::run` in the compiler still work just fine. I'm not quite sure how the rest of the runtime deals with this, but I marked process structures as `no_send` because the waiting/waking up has to happen in the same event loop right now. If processes start migrating between event loops then very bad things can happen. This may be what threadsafe I/O would fix, and I would be more than willing to rebase on that if it lands first. Anyway, for now I wanted to put this up for review, I'm still investigating the corruption/deadlock bugs, but this is in an *almost* workable state. Once I find the bugs I'll also rebase on the current master.
Diffstat (limited to 'src/rt/rust_uv.cpp')
| -rw-r--r-- | src/rt/rust_uv.cpp | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/src/rt/rust_uv.cpp b/src/rt/rust_uv.cpp index 8ef4572f810..a181e76df5c 100644 --- a/src/rt/rust_uv.cpp +++ b/src/rt/rust_uv.cpp @@ -329,20 +329,13 @@ rust_uv_get_len_from_buf(uv_buf_t buf) { return buf.len; } -extern "C" uv_err_t -rust_uv_last_error(uv_loop_t* loop) { - return uv_last_error(loop); -} - extern "C" const char* -rust_uv_strerror(uv_err_t* err_ptr) { - uv_err_t err = *err_ptr; +rust_uv_strerror(int err) { return uv_strerror(err); } extern "C" const char* -rust_uv_err_name(uv_err_t* err_ptr) { - uv_err_t err = *err_ptr; +rust_uv_err_name(int err) { return uv_err_name(err); } @@ -553,3 +546,37 @@ extern "C" uv_loop_t* rust_uv_get_loop_from_fs_req(uv_fs_t* req) { return req->loop; } +extern "C" int +rust_uv_spawn(uv_loop_t *loop, uv_process_t *p, uv_process_options_t options) { + return uv_spawn(loop, p, options); +} + +extern "C" int +rust_uv_process_kill(uv_process_t *p, int signum) { + return uv_process_kill(p, signum); +} + +extern "C" void +rust_set_stdio_container_flags(uv_stdio_container_t *c, int flags) { + c->flags = (uv_stdio_flags) flags; +} + +extern "C" void +rust_set_stdio_container_fd(uv_stdio_container_t *c, int fd) { + c->data.fd = fd; +} + +extern "C" void +rust_set_stdio_container_stream(uv_stdio_container_t *c, uv_stream_t *stream) { + c->data.stream = stream; +} + +extern "C" int +rust_uv_process_pid(uv_process_t* p) { + return p->pid; +} + +extern "C" int +rust_uv_pipe_init(uv_loop_t *loop, uv_pipe_t* p, int ipc) { + return uv_pipe_init(loop, p, ipc); +} |
