about summary refs log tree commit diff
path: root/src/libstd/rt/mod.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-11-27 09:57:05 -0800
committerbors <bors@rust-lang.org>2013-11-27 09:57:05 -0800
commite4136bd552bc7bf2b83ceb5d114f9a254bfa2b01 (patch)
tree3b5accbf93dabd0921e46e326918a1c0e5bef263 /src/libstd/rt/mod.rs
parenta6fc577ab580d09f05bb9b545b6a6511cfcb0a8f (diff)
parent5d6dbf3f262fabcb6cb920dd08be6f9d8df75d5c (diff)
downloadrust-e4136bd552bc7bf2b83ceb5d114f9a254bfa2b01.tar.gz
rust-e4136bd552bc7bf2b83ceb5d114f9a254bfa2b01.zip
auto merge of #10662 : alexcrichton/rust/thread-detach, r=pcwalton
This has one commit from a separate pull request (because these commits depend on that one), but otherwise the extra details can be found in the commit messages. The `rt::thread` module has been generally cleaned up for everyday safe usage (and it's a bug if it's not safe).
Diffstat (limited to 'src/libstd/rt/mod.rs')
-rw-r--r--src/libstd/rt/mod.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs
index 860b65b20c6..79b7dbf2aab 100644
--- a/src/libstd/rt/mod.rs
+++ b/src/libstd/rt/mod.rs
@@ -215,7 +215,8 @@ pub fn start(argc: int, argv: **u8, main: proc()) -> int {
 
     init(argc, argv);
     let exit_code = run(main);
-    cleanup();
+    // unsafe is ok b/c we're sure that the runtime is gone
+    unsafe { cleanup(); }
 
     return exit_code;
 }
@@ -228,7 +229,8 @@ pub fn start(argc: int, argv: **u8, main: proc()) -> int {
 pub fn start_on_main_thread(argc: int, argv: **u8, main: proc()) -> int {
     init(argc, argv);
     let exit_code = run_on_main_thread(main);
-    cleanup();
+    // unsafe is ok b/c we're sure that the runtime is gone
+    unsafe { cleanup(); }
 
     return exit_code;
 }
@@ -249,8 +251,17 @@ pub fn init(argc: int, argv: **u8) {
 }
 
 /// One-time runtime cleanup.
-pub fn cleanup() {
+///
+/// This function is unsafe because it performs no checks to ensure that the
+/// runtime has completely ceased running. It is the responsibility of the
+/// caller to ensure that the runtime is entirely shut down and nothing will be
+/// poking around at the internal components.
+///
+/// Invoking cleanup while portions of the runtime are still in use may cause
+/// undefined behavior.
+pub unsafe fn cleanup() {
     args::cleanup();
+    local_ptr::cleanup();
 }
 
 /// Execute the main function in a scheduler.