-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
std: complete unifying the TLS destructor list implementations
- Loading branch information
Showing
8 changed files
with
36 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#![cfg(target_thread_local)] | ||
#![unstable(feature = "thread_local_internals", issue = "none")] | ||
|
||
pub fn activate() { | ||
// run_dtors is always executed by the threading support. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! Ensures that thread-local destructors are run on thread exit. | ||
#![cfg(target_thread_local)] | ||
#![unstable(feature = "thread_local_internals", issue = "none")] | ||
|
||
use super::{abi, itron::task}; | ||
use crate::cell::Cell; | ||
use crate::sys::common::thread_local::run_dtors; | ||
|
||
#[thread_local] | ||
static REGISTERED: Cell<bool> = Cell::new(false); | ||
|
||
pub fn activate() { | ||
if !REGISTERED.get() { | ||
let tid = task::current_task_id_aborting(); | ||
// Register `tls_dtor` to make sure the TLS destructors are called | ||
// for tasks created by other means than `std::thread` | ||
unsafe { abi::SOLID_TLS_AddDestructor(tid as i32, run_dtors) }; | ||
REGISTERED.set(true); | ||
} | ||
} |