about summary refs log tree commit diff
path: root/src/libcore/task.rs
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-06-24 20:18:18 -0700
committerBrian Anderson <banderson@mozilla.com>2012-06-25 12:48:39 -0700
commitfad307d7b4aa5e7ff6cf30194b069062aaad1a89 (patch)
tree0742208560aea9aad32391f4399d5a401a9a1c8b /src/libcore/task.rs
parent3ba7ca5c9f103e17d98b4bd0d6d86e7a7c43366d (diff)
core: Convert declarations to not use the trailing 'unsafe' notation
Diffstat (limited to 'src/libcore/task.rs')
-rw-r--r--src/libcore/task.rs52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/libcore/task.rs b/src/libcore/task.rs
index ab9b4f7d3d7..73684e7c267 100644
--- a/src/libcore/task.rs
+++ b/src/libcore/task.rs
@@ -501,7 +501,7 @@ type task_id = int;
 type rust_task = libc::c_void;
 type rust_closure = libc::c_void;
 
-fn spawn_raw(opts: task_opts, +f: fn~()) unsafe {
+fn spawn_raw(opts: task_opts, +f: fn~()) {
 
     let mut f = if opts.supervise {
         f
@@ -516,25 +516,27 @@ fn spawn_raw(opts: task_opts, +f: fn~()) unsafe {
         }
     };
 
-    let fptr = ptr::addr_of(f);
-    let closure: *rust_closure = unsafe::reinterpret_cast(fptr);
+    unsafe {
+        let fptr = ptr::addr_of(f);
+        let closure: *rust_closure = unsafe::reinterpret_cast(fptr);
 
-    let new_task = alt opts.sched {
-      none {
-        rustrt::new_task()
-      }
-      some(sched_opts) {
-        new_task_in_new_sched(sched_opts)
-      }
-    };
+        let new_task = alt opts.sched {
+          none {
+            rustrt::new_task()
+          }
+          some(sched_opts) {
+            new_task_in_new_sched(sched_opts)
+          }
+        };
 
-    option::iter(opts.notify_chan) {|c|
-        // FIXME (#1087): Would like to do notification in Rust
-        rustrt::rust_task_config_notify(new_task, c);
-    }
+        option::iter(opts.notify_chan) {|c|
+            // FIXME (#1087): Would like to do notification in Rust
+            rustrt::rust_task_config_notify(new_task, c);
+        }
 
-    rustrt::start_task(new_task, closure);
-    unsafe::forget(f);
+        rustrt::start_task(new_task, closure);
+        unsafe::forget(f);
+    }
 
     fn new_task_in_new_sched(opts: sched_opts) -> *rust_task {
         if opts.native_stack_size != none {
@@ -959,7 +961,7 @@ fn test_osmain() {
 #[test]
 #[ignore(cfg(windows))]
 #[should_fail]
-fn test_unkillable() unsafe {
+fn test_unkillable() {
     import comm::methods;
     let po = comm::port();
     let ch = po.chan();
@@ -977,14 +979,16 @@ fn test_unkillable() unsafe {
         fail;
     }
 
-    unkillable {||
-        let p = ~0;
-        let pp: *uint = unsafe::transmute(p);
+    unsafe {
+        unkillable {||
+            let p = ~0;
+            let pp: *uint = unsafe::transmute(p);
 
-        // If we are killed here then the box will leak
-        po.recv();
+            // If we are killed here then the box will leak
+            po.recv();
 
-        let _p: ~int = unsafe::transmute(pp);
+            let _p: ~int = unsafe::transmute(pp);
+        }
     }
 
     // Now we can be killed