mirror of
https://github.com/servo/servo.git
synced 2025-07-03 13:33:39 +01:00
Add machinery to assert single-threadedness from geckolib.
MozReview-Commit-ID: 9LBNm2h5Ct3
This commit is contained in:
parent
a061f2a89f
commit
ac74cf7a60
2 changed files with 15 additions and 0 deletions
|
@ -1597,4 +1597,8 @@ extern "C" {
|
||||||
pub fn Gecko_GetElementsWithId ( aDocument : * const nsIDocument , aId : * mut nsAtom , ) -> * const nsTArray < * mut Element > ;
|
pub fn Gecko_GetElementsWithId ( aDocument : * const nsIDocument , aId : * mut nsAtom , ) -> * const nsTArray < * mut Element > ;
|
||||||
} extern "C" {
|
} extern "C" {
|
||||||
pub fn Gecko_GetBoolPrefValue ( pref_name : * const :: std :: os :: raw :: c_char , ) -> bool ;
|
pub fn Gecko_GetBoolPrefValue ( pref_name : * const :: std :: os :: raw :: c_char , ) -> bool ;
|
||||||
|
} extern "C" {
|
||||||
|
pub fn Gecko_IsInServoTraversal ( ) -> bool ;
|
||||||
|
} extern "C" {
|
||||||
|
pub fn Gecko_IsMainThread ( ) -> bool ;
|
||||||
}
|
}
|
|
@ -216,6 +216,16 @@ unsafe fn dummy_url_data() -> &'static RefPtr<URLExtraData> {
|
||||||
RefPtr::from_ptr_ref(&DUMMY_URL_DATA)
|
RefPtr::from_ptr_ref(&DUMMY_URL_DATA)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn is_main_thread() -> bool {
|
||||||
|
unsafe { bindings::Gecko_IsMainThread() }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn is_in_servo_traversal() -> bool {
|
||||||
|
unsafe { bindings::Gecko_IsInServoTraversal() }
|
||||||
|
}
|
||||||
|
|
||||||
fn create_shared_context<'a>(
|
fn create_shared_context<'a>(
|
||||||
global_style_data: &GlobalStyleData,
|
global_style_data: &GlobalStyleData,
|
||||||
guard: &'a SharedRwLockReadGuard,
|
guard: &'a SharedRwLockReadGuard,
|
||||||
|
@ -1335,6 +1345,7 @@ fn read_locked_arc<T, R, F>(raw: &<Locked<T> as HasFFI>::FFIType, func: F) -> R
|
||||||
unsafe fn read_locked_arc_unchecked<T, R, F>(raw: &<Locked<T> as HasFFI>::FFIType, func: F) -> R
|
unsafe fn read_locked_arc_unchecked<T, R, F>(raw: &<Locked<T> as HasFFI>::FFIType, func: F) -> R
|
||||||
where Locked<T>: HasArcFFI, F: FnOnce(&T) -> R
|
where Locked<T>: HasArcFFI, F: FnOnce(&T) -> R
|
||||||
{
|
{
|
||||||
|
debug_assert!(is_main_thread() && !is_in_servo_traversal());
|
||||||
read_locked_arc(raw, func)
|
read_locked_arc(raw, func)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue