Skip to content

Commit 4c86c13

Browse files
committed
---
yaml --- r: 104631 b: refs/heads/snap-stage3 c: e6acff8 h: refs/heads/master i: 104629: 8b049f4 104627: 755dd7a 104623: de9b018 v: v3
1 parent 0803529 commit 4c86c13

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 62f1d68439dcfd509eaca29887afa97f22938373
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d8bd8de82e19702ad26fff704ff9a4890ebe1bf7
4+
refs/heads/snap-stage3: e6acff828787b9b6c65ef66942f45e58b2f22ad6
55
refs/heads/try: db814977d07bd798feb24f6b74c00800ef458a13
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libnative/bookkeeping.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@ pub fn decrement() {
3939
/// the entry points of native programs
4040
pub fn wait_for_other_tasks() {
4141
unsafe {
42-
{
43-
let mut guard = TASK_LOCK.lock();
44-
while TASK_COUNT.load(atomics::SeqCst) > 0 {
45-
guard.wait();
46-
}
42+
let mut guard = TASK_LOCK.lock();
43+
while TASK_COUNT.load(atomics::SeqCst) > 0 {
44+
guard.wait();
4745
}
48-
TASK_LOCK.destroy();
4946
}
5047
}

branches/snap-stage3/src/libnative/io/timer_helper.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ use task;
3636
static mut HELPER_CHAN: *mut Chan<Req> = 0 as *mut Chan<Req>;
3737
static mut HELPER_SIGNAL: imp::signal = 0 as imp::signal;
3838

39+
static mut TIMER_HELPER_EXIT: StaticNativeMutex = NATIVE_MUTEX_INIT;
40+
3941
pub fn boot(helper: fn(imp::signal, Port<Req>)) {
4042
static mut LOCK: StaticNativeMutex = NATIVE_MUTEX_INIT;
4143
static mut INITIALIZED: bool = false;
@@ -53,6 +55,7 @@ pub fn boot(helper: fn(imp::signal, Port<Req>)) {
5355
task::spawn(proc() {
5456
bookkeeping::decrement();
5557
helper(receive, msgp);
58+
TIMER_HELPER_EXIT.lock().signal()
5659
});
5760

5861
rt::at_exit(proc() { shutdown() });
@@ -70,17 +73,15 @@ pub fn send(req: Req) {
7073
}
7174

7275
fn shutdown() {
73-
// We want to wait for the entire helper task to exit, and in doing so it
74-
// will attempt to decrement the global task count. When the helper was
75-
// created, it decremented the count so it wouldn't count towards preventing
76-
// the program to exit, so here we pair that manual decrement with a manual
77-
// increment. We will then wait for the helper thread to exit by calling
78-
// wait_for_other_tasks.
79-
bookkeeping::increment();
80-
8176
// Request a shutdown, and then wait for the task to exit
82-
send(Shutdown);
83-
bookkeeping::wait_for_other_tasks();
77+
unsafe {
78+
let mut guard = TIMER_HELPER_EXIT.lock();
79+
send(Shutdown);
80+
guard.wait();
81+
drop(guard);
82+
TIMER_HELPER_EXIT.destroy();
83+
}
84+
8485

8586
// Clean up after ther helper thread
8687
unsafe {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern crate native;
12+
13+
use std::io::timer;
14+
15+
#[start]
16+
fn start(argc: int, argv: **u8) -> int {
17+
native::start(argc, argv, main)
18+
}
19+
20+
fn main() {
21+
timer::sleep(250);
22+
}

0 commit comments

Comments
 (0)