mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Fixed #3386.
This commit is contained in:
parent
1b251db732
commit
670ca9894e
7 changed files with 59 additions and 8 deletions
|
@ -44,6 +44,7 @@ pub mod smallvec;
|
|||
pub mod sort;
|
||||
pub mod str;
|
||||
pub mod task;
|
||||
pub mod tid;
|
||||
pub mod time;
|
||||
pub mod vec;
|
||||
pub mod workqueue;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* 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/. */
|
||||
|
||||
#[deriving(Eq, PartialEq, Clone, Encodable, Hash)]
|
||||
#[deriving(Eq, PartialEq, Clone, Encodable, Hash, Show)]
|
||||
pub enum Namespace {
|
||||
Null,
|
||||
HTML,
|
||||
|
|
18
components/util/tid.rs
Normal file
18
components/util/tid.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
use std::sync::atomics::{AtomicUint, INIT_ATOMIC_UINT, SeqCst};
|
||||
|
||||
static mut next_tid: AtomicUint = INIT_ATOMIC_UINT;
|
||||
|
||||
local_data_key!(task_local_tid: uint)
|
||||
|
||||
/// Every task gets one, that's unique.
|
||||
pub fn tid() -> uint {
|
||||
let ret =
|
||||
match task_local_tid.replace(None) {
|
||||
None => unsafe { next_tid.fetch_add(1, SeqCst) },
|
||||
Some(x) => x,
|
||||
};
|
||||
|
||||
task_local_tid.replace(Some(ret));
|
||||
|
||||
ret
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue