pub(crate) struct JobRef {
pointer: *const (),
execute_fn: unsafe fn(*const ()),
}
Expand description
Effectively a Job trait object. Each JobRef must be executed exactly once, or else data may leak.
Internally, we store the job’s data in a *const ()
pointer. The
true type is something like *const StackJob<...>
, but we hide
it. We also carry the “execute fn” from the Job
trait.
Fields§
§pointer: *const ()
§execute_fn: unsafe fn(*const ())
Implementations§
Source§impl JobRef
impl JobRef
Sourcepub(crate) unsafe fn new<T>(data: *const T) -> JobRefwhere
T: Job,
pub(crate) unsafe fn new<T>(data: *const T) -> JobRefwhere
T: Job,
Unsafe: caller asserts that data
will remain valid until the
job is executed.
Sourcepub(crate) fn id(&self) -> impl Eq
pub(crate) fn id(&self) -> impl Eq
Returns an opaque handle that can be saved and compared,
without making JobRef
itself Copy + Eq
.
pub(crate) unsafe fn execute(self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for JobRef
impl RefUnwindSafe for JobRef
impl Unpin for JobRef
impl UnwindSafe for JobRef
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> Pointable for T
impl<T> Pointable for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes