about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-07-23 14:01:43 -0700
committerEric Holk <eholk@mozilla.com>2011-07-28 10:47:28 -0700
commitb51f5c395cc3458e428159b908ca95b1777e66e2 (patch)
treea531c23c4a54812fd6de8faee80f24f3e4607da9 /src/rt
parentc15871ac517136e216a1783d722307a1da1da106 (diff)
downloadrust-b51f5c395cc3458e428159b908ca95b1777e66e2.tar.gz
rust-b51f5c395cc3458e428159b908ca95b1777e66e2.zip
Made root_task no longer special.
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust.cpp7
-rw-r--r--src/rt/rust_kernel.cpp5
-rw-r--r--src/rt/rust_kernel.h2
-rw-r--r--src/rt/rust_scheduler.cpp3
-rw-r--r--src/rt/rust_scheduler.h2
-rw-r--r--src/rt/rust_task.cpp10
-rw-r--r--src/rt/rust_task.h3
-rw-r--r--src/rt/test/rust_test_runtime.cpp6
8 files changed, 18 insertions, 20 deletions
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp
index 029532363c8..06097e34197 100644
--- a/src/rt/rust.cpp
+++ b/src/rt/rust.cpp
@@ -144,10 +144,11 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
     rust_srv *srv = new rust_srv();
     rust_kernel *kernel = new rust_kernel(srv);
     kernel->start();
-    rust_scheduler *sched = kernel->get_scheduler();
+    rust_task *root_task = kernel->create_task(NULL, "main");
+    rust_scheduler *sched = root_task->sched;
     command_line_args *args
         = new (kernel, "main command line args")
-        command_line_args(sched->root_task, argc, argv);
+        command_line_args(root_task, argc, argv);
 
     DLOG(sched, dom, "startup: %d args in 0x%" PRIxPTR,
              args->argc, (uintptr_t)args->args);
@@ -155,7 +156,7 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
         DLOG(sched, dom, "startup: arg[%d] = '%s'", i, args->argv[i]);
     }
 
-    sched->root_task->start(main_fn, (uintptr_t)args->args);
+    root_task->start(main_fn, (uintptr_t)args->args);
 
     int num_threads = get_num_threads();
 
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index d15d52ba431..53c2d945b09 100644
--- a/src/rt/rust_kernel.cpp
+++ b/src/rt/rust_kernel.cpp
@@ -261,6 +261,11 @@ int rust_kernel::start_task_threads(int num_threads)
     return sched->rval;
 }
 
+rust_task *
+rust_kernel::create_task(rust_task *spawner, const char *name) {
+    return sched->create_task(spawner, name);
+}
+
 #ifdef __WIN32__
 void
 rust_kernel::win32_require(LPCTSTR fn, BOOL ok) {
diff --git a/src/rt/rust_kernel.h b/src/rt/rust_kernel.h
index 6edb0f38dd5..07f4ff2f787 100644
--- a/src/rt/rust_kernel.h
+++ b/src/rt/rust_kernel.h
@@ -121,6 +121,8 @@ public:
 #ifdef __WIN32__
     void win32_require(LPCTSTR fn, BOOL ok);
 #endif
+
+    rust_task *create_task(rust_task *spawner, const char *name);
 };
 
 class rust_task_thread : public rust_thread {
diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp
index 18ac66beb5e..09a78cebddb 100644
--- a/src/rt/rust_scheduler.cpp
+++ b/src/rt/rust_scheduler.cpp
@@ -16,8 +16,6 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel,
     blocked_tasks(this, "blocked"),
     dead_tasks(this, "dead"),
     cache(this),
-    root_task(NULL),
-    curr_task(NULL),
     rval(0),
     kernel(kernel),
     message_queue(message_queue)
@@ -29,7 +27,6 @@ rust_scheduler::rust_scheduler(rust_kernel *kernel,
     pthread_attr_setstacksize(&attr, 1024 * 1024);
     pthread_attr_setdetachstate(&attr, true);
 #endif
-    root_task = create_task(NULL, name);
 }
 
 rust_scheduler::~rust_scheduler() {
diff --git a/src/rt/rust_scheduler.h b/src/rt/rust_scheduler.h
index b1b9d51db56..cabcdf210a8 100644
--- a/src/rt/rust_scheduler.h
+++ b/src/rt/rust_scheduler.h
@@ -46,8 +46,6 @@ struct rust_scheduler : public kernel_owned<rust_scheduler>,
     rust_crate_cache cache;
 
     randctx rctx;
-    rust_task *root_task;
-    rust_task *curr_task;
     int rval;
 
     rust_kernel *kernel;
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index af55208582e..de6b00acb3f 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -103,8 +103,8 @@ rust_task::~rust_task()
 
     /* FIXME: tighten this up, there are some more
        assertions that hold at task-lifecycle events. */
-    I(sched, ref_count == 0 ||
-      (ref_count == 1 && this == sched->root_task));
+    // I(sched, ref_count == 0 ||
+    //   (ref_count == 1 && this == sched->root_task));
 
     del_stk(this, stk);
 }
@@ -207,8 +207,8 @@ rust_task::kill() {
     // Unblock the task so it can unwind.
     unblock();
 
-    if (this == sched->root_task)
-        sched->fail();
+    // if (this == sched->root_task)
+    //     sched->fail();
 
     LOG(this, task, "preparing to unwind task: 0x%" PRIxPTR, this);
     // run_on_resume(rust_unwind_glue);
@@ -229,8 +229,6 @@ rust_task::fail() {
         supervisor->kill();
     }
     // FIXME: implement unwinding again.
-    if (this == sched->root_task)
-        sched->fail();
     failed = true;
 }
 
diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h
index 13b5537d5d9..b1984b9d40b 100644
--- a/src/rt/rust_task.h
+++ b/src/rt/rust_task.h
@@ -123,9 +123,6 @@ rust_task : public maybe_proxy<rust_task>,
     void die();
     void unblock();
 
-    void check_active() { I(sched, sched->curr_task == this); }
-    void check_suspended() { I(sched, sched->curr_task != this); }
-
     // Print a backtrace, if the "bt" logging option is on.
     void backtrace();
 
diff --git a/src/rt/test/rust_test_runtime.cpp b/src/rt/test/rust_test_runtime.cpp
index 8acfe45c9e6..f9a99d9acb1 100644
--- a/src/rt/test/rust_test_runtime.cpp
+++ b/src/rt/test/rust_test_runtime.cpp
@@ -45,9 +45,9 @@ void task_entry() {
 
 void
 rust_task_test::worker::run() {
-    rust_scheduler *scheduler = kernel->get_scheduler();
-    scheduler->root_task->start((uintptr_t)&task_entry, (uintptr_t)NULL);
-    scheduler->start_main_loop(0);
+    rust_task *root_task = kernel->create_task(NULL, "main");
+    root_task->start((uintptr_t)&task_entry, (uintptr_t)NULL);
+    root_task->sched->start_main_loop(0);
 }
 
 bool