mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Update rustc to 00b112c45a604fa6f4b59af2a40c9deeadfdb7c6/rustc-1.0.0-dev.
This commit is contained in:
parent
ff8cbff810
commit
95fc29fa0d
255 changed files with 3550 additions and 3362 deletions
|
@ -32,15 +32,17 @@ use js::jsapi::{JS_AddObjectRoot, JS_RemoveObjectRoot, JSContext};
|
|||
|
||||
use libc;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::hash_map::{HashMap, Vacant, Occupied};
|
||||
use std::collections::hash_map::HashMap;
|
||||
use std::collections::hash_map::Entry::{Vacant, Occupied};
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
thread_local!(pub static LIVE_REFERENCES: Rc<RefCell<Option<LiveDOMReferences>>> = Rc::new(RefCell::new(None)))
|
||||
thread_local!(pub static LIVE_REFERENCES: Rc<RefCell<Option<LiveDOMReferences>>> = Rc::new(RefCell::new(None)));
|
||||
|
||||
|
||||
/// A pointer to a Rust DOM object that needs to be destroyed.
|
||||
pub struct TrustedReference(*const libc::c_void);
|
||||
unsafe impl Send for TrustedReference {}
|
||||
|
||||
/// A safe wrapper around a raw pointer to a DOM object that can be
|
||||
/// shared among tasks for use in asynchronous operations. The underlying
|
||||
|
@ -55,6 +57,8 @@ pub struct Trusted<T> {
|
|||
owner_thread: *const libc::c_void,
|
||||
}
|
||||
|
||||
unsafe impl<T: Reflectable> Send for Trusted<T> {}
|
||||
|
||||
impl<T: Reflectable> Trusted<T> {
|
||||
/// Create a new `Trusted<T>` instance from an existing DOM pointer. The DOM object will
|
||||
/// be prevented from being GCed for the duration of the resulting `Trusted<T>` object's
|
||||
|
@ -91,7 +95,7 @@ impl<T: Reflectable> Trusted<T> {
|
|||
impl<T: Reflectable> Clone for Trusted<T> {
|
||||
fn clone(&self) -> Trusted<T> {
|
||||
{
|
||||
let mut refcount = self.refcount.lock();
|
||||
let mut refcount = self.refcount.lock().unwrap();
|
||||
*refcount += 1;
|
||||
}
|
||||
|
||||
|
@ -107,7 +111,7 @@ impl<T: Reflectable> Clone for Trusted<T> {
|
|||
#[unsafe_destructor]
|
||||
impl<T: Reflectable> Drop for Trusted<T> {
|
||||
fn drop(&mut self) {
|
||||
let mut refcount = self.refcount.lock();
|
||||
let mut refcount = self.refcount.lock().unwrap();
|
||||
assert!(*refcount > 0);
|
||||
*refcount -= 1;
|
||||
if *refcount == 0 {
|
||||
|
@ -139,7 +143,7 @@ impl LiveDOMReferences {
|
|||
match table.entry(ptr as *const libc::c_void) {
|
||||
Occupied(mut entry) => {
|
||||
let refcount = entry.get_mut();
|
||||
*refcount.lock() += 1;
|
||||
*refcount.lock().unwrap() += 1;
|
||||
refcount.clone()
|
||||
}
|
||||
Vacant(entry) => {
|
||||
|
@ -148,7 +152,7 @@ impl LiveDOMReferences {
|
|||
JS_AddObjectRoot(cx, rootable);
|
||||
}
|
||||
let refcount = Arc::new(Mutex::new(1));
|
||||
entry.set(refcount.clone());
|
||||
entry.insert(refcount.clone());
|
||||
refcount
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +168,7 @@ impl LiveDOMReferences {
|
|||
let mut table = live_references.table.borrow_mut();
|
||||
match table.entry(raw_reflectable) {
|
||||
Occupied(entry) => {
|
||||
if *entry.get().lock() != 0 {
|
||||
if *entry.get().lock().unwrap() != 0 {
|
||||
// there could have been a new reference taken since
|
||||
// this message was dispatched.
|
||||
return;
|
||||
|
@ -173,7 +177,7 @@ impl LiveDOMReferences {
|
|||
unsafe {
|
||||
JS_RemoveObjectRoot(cx, (*reflectable).rootable());
|
||||
}
|
||||
let _ = entry.take();
|
||||
let _ = entry.remove();
|
||||
}
|
||||
Vacant(_) => {
|
||||
// there could be a cleanup message dispatched, then a new
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue