about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-02-12 14:36:33 -0800
committerbors <bors@rust-lang.org>2013-02-12 14:36:33 -0800
commitbc2d147847f2c8190250ddb25e3bc71b38cfaf0a (patch)
tree58ac04240d689afa51da396928a0a2583769f8a8
parent21a0d52a85895434ec1ac2f2293b89112bfc0002 (diff)
parent0db527e2f8033e49ee588b3be71f3cd7a0d13b7c (diff)
downloadrust-bc2d147847f2c8190250ddb25e3bc71b38cfaf0a.tar.gz
rust-bc2d147847f2c8190250ddb25e3bc71b38cfaf0a.zip
auto merge of #4858 : z0w0/rust/rm_weak_task_count, r=graydon
-rw-r--r--src/libcore/private/weak_task.rs12
-rw-r--r--src/rt/rust_builtin.cpp8
-rw-r--r--src/rt/rust_kernel.cpp37
-rw-r--r--src/rt/rust_kernel.h6
-rw-r--r--src/rt/rust_scheduler.cpp4
-rw-r--r--src/rt/rustrt.def.in4
6 files changed, 26 insertions, 45 deletions
diff --git a/src/libcore/private/weak_task.rs b/src/libcore/private/weak_task.rs
index e330bda0a61..520d411e4c4 100644
--- a/src/libcore/private/weak_task.rs
+++ b/src/libcore/private/weak_task.rs
@@ -41,12 +41,12 @@ pub unsafe fn weaken_task(f: &fn(Port<ShutdownMsg>)) {
     let task = get_task_id();
     // Expect the weak task service to be alive
     assert service.try_send(RegisterWeakTask(task, shutdown_chan));
-    unsafe { rust_inc_weak_task_count(); }
+    unsafe { rust_dec_kernel_live_count(); }
     do fn&() {
         let shutdown_port = swap_unwrap(&mut *shutdown_port);
         f(shutdown_port)
     }.finally || {
-        unsafe { rust_dec_weak_task_count(); }
+        unsafe { rust_inc_kernel_live_count(); }
         // Service my have already exited
         service.send(UnregisterWeakTask(task));
     }
@@ -79,11 +79,11 @@ fn create_global_service() -> ~WeakTaskService {
             let port = swap_unwrap(&mut *port);
             // The weak task service is itself a weak task
             debug!("weakening the weak service task");
-            unsafe { rust_inc_weak_task_count(); }
+            unsafe { rust_dec_kernel_live_count(); }
             run_weak_task_service(port);
         }.finally {
             debug!("unweakening the weak service task");
-            unsafe { rust_dec_weak_task_count(); }
+            unsafe { rust_inc_kernel_live_count(); }
         }
     }
 
@@ -127,8 +127,8 @@ fn run_weak_task_service(port: Port<ServiceMsg>) {
 }
 
 extern {
-    unsafe fn rust_inc_weak_task_count();
-    unsafe fn rust_dec_weak_task_count();
+    unsafe fn rust_inc_kernel_live_count();
+    unsafe fn rust_dec_kernel_live_count();
 }
 
 #[test]
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index e14f62ffae9..7c1d1a8ed16 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -939,15 +939,15 @@ rust_get_global_data_ptr() {
 }
 
 extern "C" void
-rust_inc_weak_task_count() {
+rust_inc_kernel_live_count() {
     rust_task *task = rust_get_current_task();
-    task->kernel->inc_weak_task_count();
+    task->kernel->inc_live_count();
 }
 
 extern "C" void
-rust_dec_weak_task_count() {
+rust_dec_kernel_live_count() {
     rust_task *task = rust_get_current_task();
-    task->kernel->dec_weak_task_count();
+    task->kernel->dec_live_count();
 }
 
 //
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index e0494c9300b..6b7a8241416 100644
--- a/src/rt/rust_kernel.cpp
+++ b/src/rt/rust_kernel.cpp
@@ -291,13 +291,21 @@ rust_kernel::set_exit_status(int code) {
 }
 
 void
-rust_kernel::register_task() {
-    KLOG_("Registering task");
+rust_kernel::inc_live_count() {
     uintptr_t new_non_weak_tasks = sync::increment(non_weak_tasks);
     KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks);
 }
 
 void
+rust_kernel::dec_live_count() {
+    uintptr_t new_non_weak_tasks = sync::decrement(non_weak_tasks);
+    KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks);
+    if (new_non_weak_tasks == 0) {
+        begin_shutdown();
+    }
+}
+
+void
 rust_kernel::allow_scheduler_exit() {
     scoped_lock with(sched_lock);
 
@@ -316,31 +324,6 @@ rust_kernel::allow_scheduler_exit() {
 }
 
 void
-rust_kernel::unregister_task() {
-    KLOG_("Unregistering task");
-    uintptr_t new_non_weak_tasks = sync::decrement(non_weak_tasks);
-    KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks);
-    if (new_non_weak_tasks == 0) {
-        begin_shutdown();
-    }
-}
-
-void
-rust_kernel::inc_weak_task_count() {
-    uintptr_t new_non_weak_tasks = sync::decrement(non_weak_tasks);
-    KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks);
-    if (new_non_weak_tasks == 0) {
-        begin_shutdown();
-    }
-}
-
-void
-rust_kernel::dec_weak_task_count() {
-    uintptr_t new_non_weak_tasks = sync::increment(non_weak_tasks);
-    KLOG_("New non-weak tasks %" PRIdPTR, new_non_weak_tasks);
-}
-
-void
 rust_kernel::begin_shutdown() {
     {
         scoped_lock with(sched_lock);
diff --git a/src/rt/rust_kernel.h b/src/rt/rust_kernel.h
index 11af02dace4..01ebf5ab57b 100644
--- a/src/rt/rust_kernel.h
+++ b/src/rt/rust_kernel.h
@@ -160,10 +160,8 @@ public:
     rust_sched_id main_sched_id() { return main_scheduler; }
     rust_sched_id osmain_sched_id() { return osmain_scheduler; }
 
-    void register_task();
-    void unregister_task();
-    void inc_weak_task_count();
-    void dec_weak_task_count();
+    void inc_live_count();
+    void dec_live_count();
 
     void register_exit_function(spawn_fn runner, fn_env_pair *f);
 };
diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp
index 22dae047e55..e3a5d9db91f 100644
--- a/src/rt/rust_scheduler.cpp
+++ b/src/rt/rust_scheduler.cpp
@@ -123,7 +123,7 @@ rust_scheduler::create_task(rust_task *spawner, const char *name) {
         cur_thread = (thread_no + 1) % max_num_threads;
     }
     KLOG(kernel, kern, "Creating task %s, on thread %d.", name, thread_no);
-    kernel->register_task();
+    kernel->inc_live_count();
     rust_sched_launcher *thread = threads[thread_no];
     return thread->get_loop()->create_task(spawner, name);
 }
@@ -138,7 +138,7 @@ rust_scheduler::release_task() {
             need_exit = true;
         }
     }
-    kernel->unregister_task();
+    kernel->dec_live_count();
     if (need_exit) {
         exit();
     }
diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in
index 2e687472a8d..03b18d026ad 100644
--- a/src/rt/rustrt.def.in
+++ b/src/rt/rustrt.def.in
@@ -188,6 +188,6 @@ rust_raw_thread_start
 rust_raw_thread_join_delete
 rust_register_exit_function
 rust_get_global_data_ptr
-rust_inc_weak_task_count
-rust_dec_weak_task_count
+rust_inc_kernel_live_count
+rust_dec_kernel_live_count
 rust_get_exchange_count_ptr