diff options
| author | bors <bors@rust-lang.org> | 2013-11-27 09:57:05 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-11-27 09:57:05 -0800 |
| commit | e4136bd552bc7bf2b83ceb5d114f9a254bfa2b01 (patch) | |
| tree | 3b5accbf93dabd0921e46e326918a1c0e5bef263 /src/libstd/rt/args.rs | |
| parent | a6fc577ab580d09f05bb9b545b6a6511cfcb0a8f (diff) | |
| parent | 5d6dbf3f262fabcb6cb920dd08be6f9d8df75d5c (diff) | |
| download | rust-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/args.rs')
| -rw-r--r-- | src/libstd/rt/args.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libstd/rt/args.rs b/src/libstd/rt/args.rs index 43e8096a8b1..7b27161ab5d 100644 --- a/src/libstd/rt/args.rs +++ b/src/libstd/rt/args.rs @@ -32,8 +32,8 @@ pub unsafe fn init(argc: int, argv: **u8) { imp::init(argc, argv) } pub unsafe fn init(argc: int, argv: **u8) { realargs::init(argc, argv) } /// One-time global cleanup. -#[cfg(not(test))] pub fn cleanup() { imp::cleanup() } -#[cfg(test)] pub fn cleanup() { realargs::cleanup() } +#[cfg(not(test))] pub unsafe fn cleanup() { imp::cleanup() } +#[cfg(test)] pub unsafe fn cleanup() { realargs::cleanup() } /// Take the global arguments from global storage. #[cfg(not(test))] pub fn take() -> Option<~[~str]> { imp::take() } @@ -74,14 +74,16 @@ mod imp { use vec; static mut global_args_ptr: uint = 0; + static mut lock: Mutex = MUTEX_INIT; pub unsafe fn init(argc: int, argv: **u8) { let args = load_argc_and_argv(argc, argv); put(args); } - pub fn cleanup() { + pub unsafe fn cleanup() { rtassert!(take().is_some()); + lock.destroy(); } pub fn take() -> Option<~[~str]> { @@ -108,7 +110,6 @@ mod imp { } fn with_lock<T>(f: || -> T) -> T { - static mut lock: Mutex = MUTEX_INIT; (|| { unsafe { lock.lock(); |
