mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Move script_runtime::StackRootTLS to root::ThreadLocalStackRoots
This commit is contained in:
parent
a6d01c92d9
commit
8d566fbc3c
6 changed files with 31 additions and 32 deletions
|
@ -41,6 +41,7 @@ use std::default::Default;
|
|||
use std::hash::{Hash, Hasher};
|
||||
#[cfg(debug_assertions)]
|
||||
use std::intrinsics::type_name;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem;
|
||||
use std::ops::Deref;
|
||||
use std::ptr;
|
||||
|
@ -165,6 +166,23 @@ impl Clone for RootCollectionPtr {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct ThreadLocalStackRoots<'a>(PhantomData<&'a u32>);
|
||||
|
||||
impl<'a> ThreadLocalStackRoots<'a> {
|
||||
pub fn new(roots: &'a RootCollection) -> Self {
|
||||
STACK_ROOTS.with(|ref r| {
|
||||
r.set(Some(RootCollectionPtr(roots as *const _)))
|
||||
});
|
||||
ThreadLocalStackRoots(PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Drop for ThreadLocalStackRoots<'a> {
|
||||
fn drop(&mut self) {
|
||||
STACK_ROOTS.with(|ref r| r.set(None));
|
||||
}
|
||||
}
|
||||
|
||||
impl RootCollection {
|
||||
/// Create an empty collection of roots
|
||||
pub fn new() -> RootCollection {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue