mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Move util::tid to style
This commit is contained in:
parent
e3eeb643f0
commit
744b94346a
4 changed files with 2 additions and 2 deletions
|
@ -93,6 +93,7 @@ pub mod sequential;
|
|||
pub mod servo;
|
||||
pub mod sink;
|
||||
pub mod stylesheets;
|
||||
mod tid;
|
||||
pub mod traversal;
|
||||
#[macro_use]
|
||||
#[allow(non_camel_case_types)]
|
||||
|
|
26
components/style/tid.rs
Normal file
26
components/style/tid.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize, Ordering};
|
||||
|
||||
static NEXT_TID: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
|
||||
thread_local!(static TASK_LOCAL_TID: Rc<RefCell<Option<usize>>> = Rc::new(RefCell::new(None)));
|
||||
|
||||
/// Every thread gets one, that's unique.
|
||||
pub fn tid() -> usize {
|
||||
TASK_LOCAL_TID.with(|ref k| {
|
||||
let ret =
|
||||
match *k.borrow() {
|
||||
None => NEXT_TID.fetch_add(1, Ordering::SeqCst),
|
||||
Some(x) => x,
|
||||
};
|
||||
|
||||
*k.borrow_mut() = Some(ret);
|
||||
|
||||
ret
|
||||
})
|
||||
}
|
|
@ -11,8 +11,8 @@ use selector_impl::SelectorImplExt;
|
|||
use selectors::Element;
|
||||
use selectors::bloom::BloomFilter;
|
||||
use std::cell::RefCell;
|
||||
use tid::tid;
|
||||
use util::opts;
|
||||
use util::tid::tid;
|
||||
|
||||
/// Every time we do another layout, the old bloom filters are invalid. This is
|
||||
/// detected by ticking a generation number every layout.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue