about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/rt/task.rs39
-rw-r--r--src/libstd/rt/test.rs12
-rw-r--r--src/libstd/sys.rs6
-rw-r--r--src/libstd/task/mod.rs11
-rw-r--r--src/libstd/task/spawn.rs2
5 files changed, 13 insertions, 57 deletions
diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs
index 10b4672df05..7c08dabf0bd 100644
--- a/src/libstd/rt/task.rs
+++ b/src/libstd/rt/task.rs
@@ -25,7 +25,7 @@ pub struct Task {
     gc: GarbageCollector,
     storage: LocalStorage,
     logger: StdErrLogger,
-    unwinder: Option<Unwinder>,
+    unwinder: Unwinder,
     destroyed: bool
 }
 
@@ -43,18 +43,7 @@ impl Task {
             gc: GarbageCollector,
             storage: LocalStorage(ptr::null(), None),
             logger: StdErrLogger,
-            unwinder: Some(Unwinder { unwinding: false }),
-            destroyed: false
-        }
-    }
-
-    pub fn new_root_without_unwinding() -> Task {
-        Task {
-            heap: LocalHeap::new(),
-            gc: GarbageCollector,
-            storage: LocalStorage(ptr::null(), None),
-            logger: StdErrLogger,
-            unwinder: None,
+            unwinder: Unwinder { unwinding: false },
             destroyed: false
         }
     }
@@ -65,18 +54,7 @@ impl Task {
             gc: GarbageCollector,
             storage: LocalStorage(ptr::null(), None),
             logger: StdErrLogger,
-            unwinder: Some(Unwinder { unwinding: false }),
-            destroyed: false
-        }
-    }
-
-    pub fn new_child_without_unwinding(&mut self) -> Task {
-        Task {
-            heap: LocalHeap::new(),
-            gc: GarbageCollector,
-            storage: LocalStorage(ptr::null(), None),
-            logger: StdErrLogger,
-            unwinder: None,
+            unwinder: Unwinder { unwinding: false },
             destroyed: false
         }
     }
@@ -88,16 +66,7 @@ impl Task {
             assert!(ptr::ref_eq(task, self));
         }
 
-        match self.unwinder {
-            Some(ref mut unwinder) => {
-                // If there's an unwinder then set up the catch block
-                unwinder.try(f);
-            }
-            None => {
-                // Otherwise, just run the body
-                f()
-            }
-        }
+        self.unwinder.try(f);
         self.destroy();
     }
 
diff --git a/src/libstd/rt/test.rs b/src/libstd/rt/test.rs
index 4a4d498a26e..ecfe93560b4 100644
--- a/src/libstd/rt/test.rs
+++ b/src/libstd/rt/test.rs
@@ -48,7 +48,7 @@ pub fn run_in_newsched_task(f: ~fn()) {
     do run_in_bare_thread {
         let mut sched = ~new_test_uv_sched();
         let task = ~Coroutine::with_task(&mut sched.stack_pool,
-                                         ~Task::new_root_without_unwinding(),
+                                         ~Task::new_root(),
                                          f.take());
         sched.enqueue_task(task);
         sched.run();
@@ -134,7 +134,7 @@ pub fn spawntask(f: ~fn()) {
 
     let mut task = None;
     do Local::borrow::<Task>() |running_task| {
-        task = Some(~running_task.new_child_without_unwinding());
+        task = Some(~running_task.new_child());
     }
 
     let mut sched = Local::take::<Scheduler>();
@@ -150,7 +150,7 @@ pub fn spawntask_immediately(f: ~fn()) {
 
     let mut task = None;
     do Local::borrow::<Task>() |running_task| {
-        task = Some(~running_task.new_child_without_unwinding());
+        task = Some(~running_task.new_child());
     }
 
     let mut sched = Local::take::<Scheduler>();
@@ -168,7 +168,7 @@ pub fn spawntask_later(f: ~fn()) {
 
     let mut task = None;
     do Local::borrow::<Task>() |running_task| {
-        task = Some(~running_task.new_child_without_unwinding());
+        task = Some(~running_task.new_child());
     }
 
     let mut sched = Local::take::<Scheduler>();
@@ -187,7 +187,7 @@ pub fn spawntask_random(f: ~fn()) {
 
     let mut task = None;
     do Local::borrow::<Task>() |running_task| {
-        task = Some(~running_task.new_child_without_unwinding());
+        task = Some(~running_task.new_child());
     }
 
     let mut sched = Local::take::<Scheduler>();
@@ -251,7 +251,7 @@ pub fn spawntask_thread(f: ~fn()) -> Thread {
 
     let mut task = None;
     do Local::borrow::<Task>() |running_task| {
-        task = Some(~running_task.new_child_without_unwinding());
+        task = Some(~running_task.new_child());
     }
 
     let task = Cell(task.swap_unwrap());
diff --git a/src/libstd/sys.rs b/src/libstd/sys.rs
index 137070ce202..77085d19567 100644
--- a/src/libstd/sys.rs
+++ b/src/libstd/sys.rs
@@ -226,11 +226,7 @@ pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
                 gc::cleanup_stack_for_failure();
 
                 let task = Local::unsafe_borrow::<Task>();
-                let unwinder: &mut Option<Unwinder> = &mut (*task).unwinder;
-                match *unwinder {
-                    Some(ref mut unwinder) => unwinder.begin_unwind(),
-                    None => abort!("failure without unwinder. aborting process")
-                }
+                (*task).unwinder.begin_unwind();
             }
         }
     }
diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs
index f24d2327358..faa505c1995 100644
--- a/src/libstd/task/mod.rs
+++ b/src/libstd/task/mod.rs
@@ -515,16 +515,7 @@ pub fn failing() -> bool {
         _ => {
             let mut unwinding = false;
             do Local::borrow::<Task> |local| {
-                unwinding = match local.unwinder {
-                    Some(unwinder) => {
-                        unwinder.unwinding
-                    }
-                    None => {
-                        // Because there is no unwinder we can't be unwinding.
-                        // (The process will abort on failure)
-                        false
-                    }
-                }
+                unwinding = local.unwinder.unwinding
             }
             return unwinding;
         }
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs
index a4fbec11d72..a17a6777a98 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -579,7 +579,7 @@ fn spawn_raw_newsched(_opts: TaskOpts, f: ~fn()) {
 
     let mut task = None;
     do Local::borrow::<Task>() |running_task| {
-        task = Some(~running_task.new_child_without_unwinding());
+        task = Some(~running_task.new_child());
     }
 
     let mut sched = Local::take::<Scheduler>();