From f98f76e3a75b4d75d809601ce1d6fa62d3eca428 Mon Sep 17 00:00:00 2001 From: Derek Chiang Date: Thu, 16 Jan 2014 02:24:42 +0800 Subject: Fixing a typo: bookeeping -> bookkeeping --- src/libnative/bookeeping.rs | 49 -------------------------------------------- src/libnative/bookkeeping.rs | 49 ++++++++++++++++++++++++++++++++++++++++++++ src/libnative/lib.rs | 6 +++--- src/libnative/task.rs | 8 ++++---- 4 files changed, 56 insertions(+), 56 deletions(-) delete mode 100644 src/libnative/bookeeping.rs create mode 100644 src/libnative/bookkeeping.rs (limited to 'src/libnative') diff --git a/src/libnative/bookeeping.rs b/src/libnative/bookeeping.rs deleted file mode 100644 index ca40c1a1958..00000000000 --- a/src/libnative/bookeeping.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! 1:1 Task bookeeping -//! -//! This module keeps track of the number of running 1:1 tasks so that entry -//! points with libnative know when it's possible to exit the program (once all -//! tasks have exited). -//! -//! The green counterpart for this is bookeeping on sched pools. - -use std::sync::atomics; -use std::unstable::mutex::{Mutex, MUTEX_INIT}; - -static mut TASK_COUNT: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT; -static mut TASK_LOCK: Mutex = MUTEX_INIT; - -pub fn increment() { - unsafe { TASK_COUNT.fetch_add(1, atomics::SeqCst); } -} - -pub fn decrement() { - unsafe { - if TASK_COUNT.fetch_sub(1, atomics::SeqCst) == 1 { - TASK_LOCK.lock(); - TASK_LOCK.signal(); - TASK_LOCK.unlock(); - } - } -} - -/// Waits for all other native tasks in the system to exit. This is only used by -/// the entry points of native programs -pub fn wait_for_other_tasks() { - unsafe { - TASK_LOCK.lock(); - while TASK_COUNT.load(atomics::SeqCst) > 0 { - TASK_LOCK.wait(); - } - TASK_LOCK.unlock(); - } -} diff --git a/src/libnative/bookkeeping.rs b/src/libnative/bookkeeping.rs new file mode 100644 index 00000000000..6c5f555f401 --- /dev/null +++ b/src/libnative/bookkeeping.rs @@ -0,0 +1,49 @@ +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! 1:1 Task bookkeeping +//! +//! This module keeps track of the number of running 1:1 tasks so that entry +//! points with libnative know when it's possible to exit the program (once all +//! tasks have exited). +//! +//! The green counterpart for this is bookkeeping on sched pools. + +use std::sync::atomics; +use std::unstable::mutex::{Mutex, MUTEX_INIT}; + +static mut TASK_COUNT: atomics::AtomicUint = atomics::INIT_ATOMIC_UINT; +static mut TASK_LOCK: Mutex = MUTEX_INIT; + +pub fn increment() { + unsafe { TASK_COUNT.fetch_add(1, atomics::SeqCst); } +} + +pub fn decrement() { + unsafe { + if TASK_COUNT.fetch_sub(1, atomics::SeqCst) == 1 { + TASK_LOCK.lock(); + TASK_LOCK.signal(); + TASK_LOCK.unlock(); + } + } +} + +/// Waits for all other native tasks in the system to exit. This is only used by +/// the entry points of native programs +pub fn wait_for_other_tasks() { + unsafe { + TASK_LOCK.lock(); + while TASK_COUNT.load(atomics::SeqCst) > 0 { + TASK_LOCK.wait(); + } + TASK_LOCK.unlock(); + } +} diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index 584314ca04a..f69ad8fc1aa 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -29,7 +29,7 @@ use std::os; use std::rt; -mod bookeeping; +mod bookkeeping; pub mod io; pub mod task; @@ -75,6 +75,6 @@ pub fn start(argc: int, argv: **u8, main: proc()) -> int { /// number of arguments. pub fn run(main: proc()) -> int { main(); - bookeeping::wait_for_other_tasks(); + bookkeeping::wait_for_other_tasks(); os::get_exit_status() } diff --git a/src/libnative/task.rs b/src/libnative/task.rs index e827b495852..d2f68c4ef68 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -27,7 +27,7 @@ use std::unstable::stack; use io; use task; -use bookeeping; +use bookkeeping; /// Creates a new Task which is ready to execute as a 1:1 task. pub fn new(stack_bounds: (uint, uint)) -> ~Task { @@ -82,7 +82,7 @@ pub fn spawn_opts(opts: TaskOpts, f: proc()) { // Note that this increment must happen *before* the spawn in order to // guarantee that if this task exits it will always end up waiting for the // spawned task to exit. - bookeeping::increment(); + bookkeeping::increment(); // Spawning a new OS thread guarantees that __morestack will never get // triggered, but we must manually set up the actual stack bounds once this @@ -104,7 +104,7 @@ pub fn spawn_opts(opts: TaskOpts, f: proc()) { let mut task = task; task.put_runtime(ops as ~rt::Runtime); task.run(|| { f.take_unwrap()() }); - bookeeping::decrement(); + bookkeeping::decrement(); }) } -- cgit 1.4.1-3-g733a5