Struct style::scoped_tls::ScopedTLS
[−]
[src]
pub struct ScopedTLS<'scope, T: Send> { /* fields omitted */ }
A scoped TLS set, that is alive during the 'scope
lifetime.
We use this on Servo to construct thread-local contexts, but clear them once we're done with restyling.
Methods
impl<'scope, T: Send> ScopedTLS<'scope, T>
[src]
pub fn new(p: &'scope ThreadPool) -> Self
[src]
Create a new scoped TLS that will last as long as this rayon threadpool reference.
pub fn borrow(&self) -> Ref<Option<T>>
[src]
Return an immutable reference to the Option<T>
that this thread owns.
pub fn borrow_mut(&self) -> RefMut<Option<T>>
[src]
Return a mutable reference to the Option<T>
that this thread owns.
pub fn ensure<F: FnOnce(&mut Option<T>)>(&self, f: F) -> RefMut<T>
[src]
Ensure that the current data this thread owns is initialized, or
initialize it using f
. We want ensure() to be fast and inline, and we
want to inline the memmove that initializes the Optionf
a mutable borrow to write to instead of just
having it return a T.
pub unsafe fn unsafe_get(&self) -> &[RefCell<Option<T>>]
[src]
Unsafe access to the slots. This can be used to access the TLS when the caller knows that the pool does not have access to the TLS.
Trait Implementations
impl<'scope, T: Send> Sync for ScopedTLS<'scope, T>
[src]
The scoped TLS is Sync
because no more than one worker thread can access a
given slot.