mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-23 21:23:20 +00:00
std: Move loop creation into run_high_level_loop
This commit is contained in:
parent
2a82a9907f
commit
444ff687a2
@ -101,11 +101,9 @@ fn spawn_high_level_loop() -> hl::high_level_loop unsafe {
|
|||||||
#debug("entering global libuv task");
|
#debug("entering global libuv task");
|
||||||
weaken_task() {|weak_exit_po|
|
weaken_task() {|weak_exit_po|
|
||||||
#debug("global libuv task is now weak %?", weak_exit_po);
|
#debug("global libuv task is now weak %?", weak_exit_po);
|
||||||
let loop_ptr = ll::loop_new();
|
|
||||||
let loop_msg_po = port::<hl::high_level_msg>();
|
let loop_msg_po = port::<hl::high_level_msg>();
|
||||||
let loop_msg_ch = loop_msg_po.chan();
|
let loop_msg_ch = loop_msg_po.chan();
|
||||||
hl::run_high_level_loop(
|
hl::run_high_level_loop(
|
||||||
loop_ptr,
|
|
||||||
loop_msg_po,
|
loop_msg_po,
|
||||||
// before_run
|
// before_run
|
||||||
{|async_handle|
|
{|async_handle|
|
||||||
@ -128,7 +126,6 @@ fn spawn_high_level_loop() -> hl::high_level_loop unsafe {
|
|||||||
async_handle);
|
async_handle);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ll::loop_delete(loop_ptr);
|
|
||||||
#debug("global libuv task is leaving weakened state");
|
#debug("global libuv task is leaving weakened state");
|
||||||
};
|
};
|
||||||
#debug("global libuv task exiting");
|
#debug("global libuv task exiting");
|
||||||
|
@ -60,12 +60,12 @@ the loop's msg port
|
|||||||
* before_tear_down - called just before the loop invokes `uv_close()` on the
|
* before_tear_down - called just before the loop invokes `uv_close()` on the
|
||||||
provided `async_handle`. `uv_run` should return shortly after
|
provided `async_handle`. `uv_run` should return shortly after
|
||||||
"]
|
"]
|
||||||
unsafe fn run_high_level_loop(loop_ptr: *c_void,
|
unsafe fn run_high_level_loop(msg_po: port<high_level_msg>,
|
||||||
msg_po: port<high_level_msg>,
|
|
||||||
before_run: fn~(*ll::uv_async_t),
|
before_run: fn~(*ll::uv_async_t),
|
||||||
before_msg_process:
|
before_msg_process:
|
||||||
fn~(*ll::uv_async_t, bool) -> bool,
|
fn~(*ll::uv_async_t, bool) -> bool,
|
||||||
before_tear_down: fn~(*ll::uv_async_t)) {
|
before_tear_down: fn~(*ll::uv_async_t)) {
|
||||||
|
let loop_ptr = ll::loop_new();
|
||||||
// set up the special async handle we'll use to allow multi-task
|
// set up the special async handle we'll use to allow multi-task
|
||||||
// communication with this loop
|
// communication with this loop
|
||||||
let async = ll::async_t();
|
let async = ll::async_t();
|
||||||
@ -90,6 +90,7 @@ unsafe fn run_high_level_loop(loop_ptr: *c_void,
|
|||||||
// enter the loop... this blocks until the loop is done..
|
// enter the loop... this blocks until the loop is done..
|
||||||
ll::run(loop_ptr);
|
ll::run(loop_ptr);
|
||||||
log(debug, "high-level loop ended");
|
log(debug, "high-level loop ended");
|
||||||
|
ll::loop_delete(loop_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc = "
|
#[doc = "
|
||||||
@ -233,11 +234,9 @@ mod test {
|
|||||||
let hl_loop_port = comm::port::<high_level_loop>();
|
let hl_loop_port = comm::port::<high_level_loop>();
|
||||||
let hl_loop_ch = comm::chan(hl_loop_port);
|
let hl_loop_ch = comm::chan(hl_loop_port);
|
||||||
task::spawn_sched(task::manual_threads(1u)) {||
|
task::spawn_sched(task::manual_threads(1u)) {||
|
||||||
let loop_ptr = ll::loop_new();
|
|
||||||
let msg_po = comm::port::<high_level_msg>();
|
let msg_po = comm::port::<high_level_msg>();
|
||||||
let msg_ch = comm::chan(msg_po);
|
let msg_ch = comm::chan(msg_po);
|
||||||
run_high_level_loop(
|
run_high_level_loop(
|
||||||
loop_ptr,
|
|
||||||
msg_po,
|
msg_po,
|
||||||
// before_run
|
// before_run
|
||||||
{|async_handle|
|
{|async_handle|
|
||||||
@ -261,7 +260,6 @@ mod test {
|
|||||||
log(debug,#fmt("hl test_loop b4_tear_down: async %?",
|
log(debug,#fmt("hl test_loop b4_tear_down: async %?",
|
||||||
async_handle));
|
async_handle));
|
||||||
});
|
});
|
||||||
ll::loop_delete(loop_ptr);
|
|
||||||
comm::send(exit_ch, ());
|
comm::send(exit_ch, ());
|
||||||
};
|
};
|
||||||
ret comm::recv(hl_loop_port);
|
ret comm::recv(hl_loop_port);
|
||||||
|
Loading…
Reference in New Issue
Block a user