Struct tracing::span::PhantomNotSend
source · struct PhantomNotSend {
ghost: PhantomData<*mut ()>,
}
Expand description
Technically, EnteredSpan
can implement both Send
and
Sync
safely. It doesn’t, because it has a PhantomNotSend
field,
specifically added in order to make it !Send
.
Sending an EnteredSpan
guard between threads cannot cause memory unsafety.
However, it would result in incorrect behavior, so we add a
PhantomNotSend
to prevent it from being sent between threads. This is
because it must be dropped on the same thread that it was created;
otherwise, the span will never be exited on the thread where it was entered,
and it will attempt to exit the span on a thread that may never have entered
it. However, we still want them to be Sync
so that a struct holding an
Entered
guard can be Sync
.
Thus, this is totally safe.
Fields§
§ghost: PhantomData<*mut ()>
Trait Implementations§
source§impl Debug for PhantomNotSend
impl Debug for PhantomNotSend
impl Sync for PhantomNotSend
§Safety
Trivially safe, as PhantomNotSend
doesn’t have any API.