Skip to content

Commit 79530ac

Browse files
committed
---
yaml --- r: 13038 b: refs/heads/master c: 95898b4 h: refs/heads/master v: v3
1 parent 358d8c2 commit 79530ac

File tree

3 files changed

+16
-49
lines changed

3 files changed

+16
-49
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 623acaa0139b77984ec93a0e0002b7149343ae37
2+
refs/heads/master: 95898b4cfcbc5b47730aa722f3818f8b9028cb63
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libstd/uv_global_loop.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,29 +94,20 @@ fn get_monitor_task_gl() -> hl::high_level_loop unsafe {
9494
}
9595

9696
fn spawn_high_level_loop() -> hl::high_level_loop unsafe {
97-
let exit_po = port::<hl::high_level_loop>();
98-
let exit_ch = exit_po.chan();
97+
let hll_po = port::<hl::high_level_loop>();
98+
let hll_ch = hll_po.chan();
9999

100100
spawn_sched(single_threaded) {||
101101
#debug("entering global libuv task");
102102
weaken_task() {|weak_exit_po|
103103
#debug("global libuv task is now weak %?", weak_exit_po);
104-
let loop_msg_po = port::<hl::high_level_msg>();
105-
let loop_msg_ch = loop_msg_po.chan();
106-
hl::run_high_level_loop(loop_msg_po) {|async_handle|
107-
#debug("global libuv: before_run %?", async_handle);
108-
let hll = hl::high_level_loop({
109-
async_handle: async_handle,
110-
op_chan: loop_msg_ch
111-
});
112-
exit_ch.send(hll);
113-
}
104+
hl::run_high_level_loop(hll_ch);
114105
#debug("global libuv task is leaving weakened state");
115106
};
116107
#debug("global libuv task exiting");
117108
};
118109

119-
exit_po.recv()
110+
hll_po.recv()
120111
}
121112

122113
#[cfg(test)]

trunk/src/libstd/uv_hl.rs

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,9 @@ closed, causing a failure otherwise. This should not be sent/used from
4141

4242
#[doc = "
4343
Useful for anyone who wants to roll their own `high_level_loop`.
44-
45-
# Arguments
46-
47-
* loop_ptr - a pointer to a currently unused libuv loop. Its `data` field
48-
will be overwritten before the loop begins
49-
* msg_po - an active port that receives `high_level_msg`s. You can distribute
50-
a paired channel to users, along with the `async_handle` returned in the
51-
following callback (combine them to make a `hl::simpler_task_loop` varient
52-
of `hl::high_level_loop`)
53-
* before_run - a unique closure that is invoked before `uv_run()` is called
54-
on the provided `loop_ptr`. An `async_handle` is passed in which will be
55-
live for the duration of the loop. You can distribute this to users so that
56-
they can interact with the loop safely.
57-
* before_msg_process - a unique closure that is invoked at least once when
58-
the loop is woken up, and once more for every message that is drained from
59-
the loop's msg port
60-
* before_tear_down - called just before the loop invokes `uv_close()` on the
61-
provided `async_handle`. `uv_run` should return shortly after
6244
"]
63-
unsafe fn run_high_level_loop(msg_po: port<high_level_msg>,
64-
before_run: fn~(*ll::uv_async_t)) {
45+
unsafe fn run_high_level_loop(hll_ch: chan<high_level_loop>) {
46+
let msg_po = port::<high_level_msg>();
6547
let loop_ptr = ll::loop_new();
6648
// set up the special async handle we'll use to allow multi-task
6749
// communication with this loop
@@ -78,8 +60,13 @@ unsafe fn run_high_level_loop(msg_po: port<high_level_msg>,
7860
};
7961
ll::set_data_for_uv_handle(async_handle, addr_of(data));
8062

81-
// call before_run
82-
before_run(async_handle);
63+
// Send out a handle through which folks can talk to us
64+
// while we dwell in the I/O loop
65+
let hll = high_level_loop({
66+
async_handle: async_handle,
67+
op_chan: msg_po.chan()
68+
});
69+
hll_ch.send(hll);
8370

8471
log(debug, "about to run high level loop");
8572
// enter the loop... this blocks until the loop is done..
@@ -224,19 +211,8 @@ mod test {
224211
let hl_loop_port = comm::port::<high_level_loop>();
225212
let hl_loop_ch = comm::chan(hl_loop_port);
226213
task::spawn_sched(task::manual_threads(1u)) {||
227-
let msg_po = comm::port::<high_level_msg>();
228-
let msg_ch = comm::chan(msg_po);
229-
run_high_level_loop(msg_po) {|async_handle|
230-
log(debug,#fmt("hltest before_run: async_handle %?",
231-
async_handle));
232-
// do an async_send with it
233-
ll::async_send(async_handle);
234-
comm::send(hl_loop_ch, high_level_loop({
235-
async_handle: async_handle,
236-
op_chan: msg_ch
237-
}));
238-
}
239-
comm::send(exit_ch, ());
214+
run_high_level_loop(hl_loop_ch);
215+
exit_ch.send(());
240216
};
241217
ret comm::recv(hl_loop_port);
242218
}

0 commit comments

Comments
 (0)