mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Clean up some code related to #[no_move].
The patch makes RootCollection a bit safer by making the StackRootTLS hold it in place. The use of no_move in CodeGenRust was leftover from when roots couldn't be moved.
This commit is contained in:
parent
db1163b1ec
commit
1a50fce67c
5 changed files with 25 additions and 24 deletions
|
@ -89,6 +89,7 @@ use std::borrow::ToOwned;
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::HashSet;
|
||||
use std::io::{Write, stdout};
|
||||
use std::marker::PhantomData;
|
||||
use std::mem as std_mem;
|
||||
use std::option::Option;
|
||||
use std::ptr;
|
||||
|
@ -334,18 +335,18 @@ impl TimerEventChan for MainThreadTimerEventChan {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct StackRootTLS;
|
||||
pub struct StackRootTLS<'a>(PhantomData<&'a u32>);
|
||||
|
||||
impl StackRootTLS {
|
||||
pub fn new(roots: &RootCollection) -> StackRootTLS {
|
||||
impl<'a> StackRootTLS<'a> {
|
||||
pub fn new(roots: &'a RootCollection) -> StackRootTLS<'a> {
|
||||
STACK_ROOTS.with(|ref r| {
|
||||
r.set(Some(RootCollectionPtr(roots as *const _)))
|
||||
});
|
||||
StackRootTLS
|
||||
StackRootTLS(PhantomData)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for StackRootTLS {
|
||||
impl<'a> Drop for StackRootTLS<'a> {
|
||||
fn drop(&mut self) {
|
||||
STACK_ROOTS.with(|ref r| r.set(None));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue