Skip to main content

owned_task

Macro owned_task 

Source
macro_rules! owned_task {
    ([$($gen:tt)*] $ty:ty, $field:ident) => { ... };
    ($ty:ty, $field:ident) => { ... };
}
Expand description

Implements OwnedTask (and the required Send) for a struct that embeds an intrusive task: Task field and is scheduled fire-and-forget via WorkPool::schedule_owned. Expands to [intrusive_work_task!] + unsafe impl Send + the run forward — the implementor supplies only an inherent fn run_owned(self: Box<Self>).

The Send impl is part of the macro because every OwnedTask is by construction sent to a worker thread — Zig’s WorkPool.schedule had no such bound and the per-type fields (raw *mut EventLoop, *const JSGlobalObject) are auto-!Send only nominally. The safety obligation (“all fields are sound to move across threads”) is restated once here rather than at every WorkPool::schedule(addr_of_mut!((*p).task)) site.