mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Update rustc to revision 2cfb5acb5a2751c759627377e602bac4f88f2d19.
This commit is contained in:
parent
cf616b90a2
commit
16c7060bc8
153 changed files with 2095 additions and 1298 deletions
|
@ -3,20 +3,24 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::sync::atomic::{AtomicUint, INIT_ATOMIC_UINT, SeqCst};
|
||||
use std::rc::Rc;
|
||||
use std::cell::RefCell;
|
||||
|
||||
static mut next_tid: AtomicUint = INIT_ATOMIC_UINT;
|
||||
|
||||
local_data_key!(task_local_tid: uint)
|
||||
thread_local!(static task_local_tid: Rc<RefCell<Option<uint>>> = Rc::new(RefCell::new(None)))
|
||||
|
||||
/// 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.with(|ref k| {
|
||||
let ret =
|
||||
match *k.borrow() {
|
||||
None => unsafe { next_tid.fetch_add(1, SeqCst) },
|
||||
Some(x) => x,
|
||||
};
|
||||
|
||||
task_local_tid.replace(Some(ret));
|
||||
*k.borrow_mut() = Some(ret);
|
||||
|
||||
ret
|
||||
ret
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue