pub struct ThreadMutex<T: 'static> { /* private fields */ }Expand description
A Mutex whose contents are the shell thread’s on the shell thread and
this thread’s own everywhere else.
!!! WARNING: RUST-ONLY !!! No counterpart in Src/*.c — C gets this
split from fork(2).
The API is deliberately Mutex’s, down to the LockResult, so a
global can be re-typed from Mutex<T> to ThreadMutex<T> without
touching its readers. The per-thread halves are leaked Mutex<T>s so
both branches can hand back the same MutexGuard<'static, T> type; the
leak is bounded by (threads that ever ran shell code) × (cells), which
is the small fixed worker pool.
A worker’s half starts EMPTY rather than as a copy of the shell
thread’s. That is the fork() a C zsh would do from preprompt(),
where the shell is at top level with nothing on any of these stacks;
it is not a copy of an arbitrary mid-function state, because no site
that runs shell code off the shell thread is reached from inside one.
Implementations§
Source§impl<T: 'static> ThreadMutex<T>
impl<T: 'static> ThreadMutex<T>
Sourcepub const fn new(shell: T, seed: fn() -> T) -> Self
pub const fn new(shell: T, seed: fn() -> T) -> Self
shell is the shell thread’s initial value; seed builds a
non-shell thread’s. const so the consumer stays a plain static.
Sourcepub fn lock(&'static self) -> LockResult<MutexGuard<'static, T>>
pub fn lock(&'static self) -> LockResult<MutexGuard<'static, T>>
Mirrors Mutex::lock.
Sourcepub fn try_lock(&'static self) -> TryLockResult<MutexGuard<'static, T>>
pub fn try_lock(&'static self) -> TryLockResult<MutexGuard<'static, T>>
Mirrors Mutex::try_lock.
Sourcepub fn clear_poison(&'static self)
pub fn clear_poison(&'static self)
Mirrors Mutex::clear_poison.
Auto Trait Implementations§
impl<T> !Freeze for ThreadMutex<T>
impl<T> RefUnwindSafe for ThreadMutex<T>where
Mutex<T>: RefUnwindSafe,
fn() -> T: RefUnwindSafe,
Mutex<Option<HashMap<ThreadId, &'static Mutex<T>>>>: RefUnwindSafe,
impl<T> Send for ThreadMutex<T>
impl<T> Sync for ThreadMutex<T>
impl<T> Unpin for ThreadMutex<T>
impl<T> UnsafeUnpin for ThreadMutex<T>where
Mutex<T>: UnsafeUnpin,
fn() -> T: UnsafeUnpin,
Mutex<Option<HashMap<ThreadId, &'static Mutex<T>>>>: UnsafeUnpin,
impl<T> UnwindSafe for ThreadMutex<T>where
Mutex<T>: UnwindSafe,
fn() -> T: UnwindSafe,
Mutex<Option<HashMap<ThreadId, &'static Mutex<T>>>>: UnwindSafe,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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