task -> thread

This commit is contained in:
rohan.prinja 2015-11-14 05:07:55 +09:00 committed by Rohan Prinja
parent f00532bab0
commit 1f02c4ebbb
119 changed files with 1209 additions and 1207 deletions

View file

@ -7,8 +7,8 @@
use dom::bindings::trace::JSTraceable;
use js::jsapi::JSTracer;
use std::cell::{BorrowState, Ref, RefCell, RefMut};
use util::task_state;
use util::task_state::SCRIPT;
use util::thread_state;
use util::thread_state::SCRIPT;
/// A mutable field in the DOM.
///
@ -25,10 +25,10 @@ pub struct DOMRefCell<T> {
impl<T> DOMRefCell<T> {
/// Return a reference to the contents.
///
/// For use in the layout task only.
/// For use in the layout thread only.
#[allow(unsafe_code)]
pub unsafe fn borrow_for_layout(&self) -> &T {
debug_assert!(task_state::get().is_layout());
debug_assert!(thread_state::get().is_layout());
&*self.value.as_unsafe_cell().get()
}
@ -40,7 +40,7 @@ impl<T> DOMRefCell<T> {
pub unsafe fn borrow_for_gc_trace(&self) -> &T {
// FIXME: IN_GC isn't reliable enough - doesn't catch minor GCs
// https://github.com/servo/servo/issues/6389
// debug_assert!(task_state::get().contains(SCRIPT | IN_GC));
// debug_assert!(thread_state::get().contains(SCRIPT | IN_GC));
&*self.value.as_unsafe_cell().get()
}
@ -48,7 +48,7 @@ impl<T> DOMRefCell<T> {
///
#[allow(unsafe_code)]
pub unsafe fn borrow_for_script_deallocation(&self) -> &mut T {
debug_assert!(task_state::get().contains(SCRIPT));
debug_assert!(thread_state::get().contains(SCRIPT));
&mut *self.value.as_unsafe_cell().get()
}
@ -70,7 +70,7 @@ impl<T> DOMRefCell<T> {
///
/// Panics if this is called off the script thread.
pub fn try_borrow(&self) -> Option<Ref<T>> {
debug_assert!(task_state::get().is_script());
debug_assert!(thread_state::get().is_script());
match self.value.borrow_state() {
BorrowState::Writing => None,
_ => Some(self.value.borrow()),
@ -88,17 +88,17 @@ impl<T> DOMRefCell<T> {
///
/// Panics if this is called off the script thread.
pub fn try_borrow_mut(&self) -> Option<RefMut<T>> {
debug_assert!(task_state::get().is_script());
debug_assert!(thread_state::get().is_script());
match self.value.borrow_state() {
BorrowState::Unused => Some(self.value.borrow_mut()),
_ => None,
}
}
/// Version of the above that we use during restyle while the script task
/// Version of the above that we use during restyle while the script thread
/// is blocked.
pub fn borrow_mut_for_layout(&self) -> RefMut<T> {
debug_assert!(task_state::get().is_layout());
debug_assert!(thread_state::get().is_layout());
self.value.borrow_mut()
}
}