mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-04 19:29:07 +00:00
argue why at_exit_imp is fine
This commit is contained in:
parent
22457deef7
commit
ab3e4a2789
@ -64,6 +64,7 @@ pub fn cleanup() {
|
|||||||
if !queue.is_null() {
|
if !queue.is_null() {
|
||||||
let queue: Box<Queue> = Box::from_raw(queue);
|
let queue: Box<Queue> = Box::from_raw(queue);
|
||||||
for to_run in *queue {
|
for to_run in *queue {
|
||||||
|
// We are not holding any lock, so reentrancy is fine.
|
||||||
to_run();
|
to_run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,9 +76,8 @@ pub fn push(f: Box<dyn FnBox()>) -> bool {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let _guard = LOCK.lock();
|
let _guard = LOCK.lock();
|
||||||
if init() {
|
if init() {
|
||||||
// This could reentrantly call `push` again, which is a problem because
|
// We are just moving `f` around, not calling it.
|
||||||
// `LOCK` allows reentrancy!
|
// There is no possibility of reentrancy here.
|
||||||
// FIXME: Add argument why this is okay.
|
|
||||||
(*QUEUE).push(f);
|
(*QUEUE).push(f);
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user