pub struct WorkerHandle {
pub script_url: String,
pub closing: Arc<AtomicBool>,
pub terminated: Arc<AtomicBool>,
/* private fields */
}Expand description
A Send+Sync handle to a servo Worker’s lifecycle state.
Does NOT hold JSObject references — only atomic flags and the global address (for REALM_PROFILES cleanup on teardown). This is safe to store across threads (unlike Worker DOM objects).
@trace REQ-BRW-004 [entity:Worker]
Fields§
§script_url: StringWorker script URL.
closing: Arc<AtomicBool>Mirrors servo Worker::closing — set by terminate() or self.close().
terminated: Arc<AtomicBool>Mirrors servo Worker::terminated — true after full teardown.
Implementations§
Source§impl WorkerHandle
impl WorkerHandle
Sourcepub fn new(script_url: String) -> Self
pub fn new(script_url: String) -> Self
Create a new WorkerHandle in the running state.
@trace REQ-BRW-004 [entity:Worker]
Sourcepub fn is_closing(&self) -> bool
pub fn is_closing(&self) -> bool
Returns true if terminate()/self.close() has been requested.
@trace REQ-BRW-004 [entity:Worker]
Sourcepub fn is_terminated(&self) -> bool
pub fn is_terminated(&self) -> bool
Returns true if the Worker thread has fully exited.
@trace REQ-BRW-004 [entity:Worker]
Sourcepub fn terminate(&self)
pub fn terminate(&self)
Signal the Worker to terminate (mirrors Worker::terminate()). Idempotent — calling multiple times is safe.
@trace REQ-BRW-004 [entity:Worker]
Sourcepub fn mark_terminated(&self)
pub fn mark_terminated(&self)
Mark the Worker as fully terminated (called after thread join).
@trace REQ-BRW-004 [entity:Worker]
Sourcepub fn set_worker_global_addr(&self, addr: usize)
pub fn set_worker_global_addr(&self, addr: usize)
Set the Worker’s global object address for REALM_PROFILES tracking.
Called from the worker thread’s scope_init callback after the global object is created. The address is used on teardown to unregister the stealth profile from REALM_PROFILES (SPEC criterion #18).
@trace REQ-BRW-004 [criterion:18] REALM_PROFILES 条目注销
Sourcepub fn worker_global_addr(&self) -> usize
pub fn worker_global_addr(&self) -> usize
Get the Worker’s global object address (0 if not yet set).
@trace REQ-BRW-004 [criterion:18] REALM_PROFILES 条目注销
Sourcepub fn worker_global_addr_arc(&self) -> Arc<AtomicU64> ⓘ
pub fn worker_global_addr_arc(&self) -> Arc<AtomicU64> ⓘ
Get a clone of the Arc
This allows the scope_init callback on the worker thread to write the global address into the same slot that the main thread’s WorkerHandle reads from — without any JSObject references crossing the thread boundary (BCE-20260621-001: thread-local JSContext invariant).
@trace REQ-BRW-004 [criterion:18] REALM_PROFILES 条目注销
Sourcepub fn unregister_stealth_profile(&self)
pub fn unregister_stealth_profile(&self)
Unregister the Worker’s stealth profile from REALM_PROFILES.
Called during crash-safe teardown (all three paths) to ensure the profile entry for this Worker’s global is removed, preventing stale entries that could cause UAF or fingerprint leakage.
SPEC criterion #18: “REALM_PROFILES 条目注销”
@trace REQ-BRW-004 [criterion:18] REALM_PROFILES 条目注销
Trait Implementations§
Source§impl Clone for WorkerHandle
impl Clone for WorkerHandle
Source§fn clone(&self) -> WorkerHandle
fn clone(&self) -> WorkerHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for WorkerHandle
impl RefUnwindSafe for WorkerHandle
impl Send for WorkerHandle
impl Sync for WorkerHandle
impl Unpin for WorkerHandle
impl UnsafeUnpin for WorkerHandle
impl UnwindSafe for WorkerHandle
Blanket Implementations§
Source§impl<T> AsCtxPtr for Twhere
T: ?Sized,
impl<T> AsCtxPtr for Twhere
T: ?Sized,
Source§fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
self’s address as *mut Self for deferred-task / scopeguard /
ref_guard ctx slots. The closures/trampolines deref it as shared
(&*p) — every method they reach is &self post-R-2, so no write
provenance is required; the *mut spelling is purely to match the
existing DerefOnDrop / HasAutoFlush / RefCount ABI.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more