diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-21 11:08:15 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-21 11:14:58 -0700 |
| commit | 1ec9adcfc0da7b1cdfe8d42f7eedcbd727c6861c (patch) | |
| tree | 76ff033c4dce8b2327b28d8b6fc5a2555f05c524 /src/libstd/sys/common/helper_thread.rs | |
| parent | ecf8c64e1b1b60f228f0c472c0b0dab4a5b5aa61 (diff) | |
| download | rust-1ec9adcfc0da7b1cdfe8d42f7eedcbd727c6861c.tar.gz rust-1ec9adcfc0da7b1cdfe8d42f7eedcbd727c6861c.zip | |
std: Tweak rt::at_exit behavior
There have been some recent panics on the bots and this commit is an attempt to appease them. Previously it was considered invalid to run `rt::at_exit` after the handlers had already started running. Due to the multithreaded nature of applications, however, it is not always possible to guarantee this. For example [this program][ex] will show off the abort. [ex]: https://gist.github.com/alexcrichton/56300b87af6fa554e52d The semantics of the `rt::at_exit` function have been modified as such: * It is now legal to call `rt::at_exit` at any time. The return value now indicates whether the closure was successfully registered or not. Callers must now decide what to do with this information. * The `rt::at_exit` handlers will now be run for a fixed number of iterations. Common cases (such as the example shown) may end up registering a new handler while others are running perhaps once or twice, so this common condition is covered by re-running the handlers a fixed number of times, after which new registrations are forbidden. Some usage of `rt::at_exit` was updated to handle these new semantics, but deprecated or unstable libraries calling `rt::at_exit` were not updated.
Diffstat (limited to 'src/libstd/sys/common/helper_thread.rs')
| -rw-r--r-- | src/libstd/sys/common/helper_thread.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstd/sys/common/helper_thread.rs b/src/libstd/sys/common/helper_thread.rs index 2a852fbcd57..53f18a57325 100644 --- a/src/libstd/sys/common/helper_thread.rs +++ b/src/libstd/sys/common/helper_thread.rs @@ -112,7 +112,7 @@ impl<M: Send> Helper<M> { self.cond.notify_one() }); - rt::at_exit(move || { self.shutdown() }); + let _ = rt::at_exit(move || { self.shutdown() }); *self.initialized.get() = true; } else if *self.chan.get() as uint == 1 { panic!("cannot continue usage after shutdown"); |
