Creates a new `ScopedFutureJob` in an `Arc`. The caller is expected to immediately call `into_job_ref` and queue it on a worker to be polled.
(
scope: &Scope<'scope, 'env>,
scheduler: S,
future: Fut,
)
| 621 | scheduler: S, |
| 622 | ) { |
| 623 | // Record the scope in the storage, so the job can find it while it |
| 624 | // runs. |
| 625 | self.claim(ptr::from_ref(scope).cast_mut().cast()); |
| 626 | // Keep the scope open until the job has run. The pointer recorded by |
| 627 | // the claim doubles as this reference: `ScopedJobStorage::execute` |
| 628 | // rebuilds the `ScopePtr` from it with `ScopePtr::from_raw`. The |
| 629 | // reference is taken only after the claim succeeds, because `claim` |
| 630 | // panics if the storage is already pending, and a reference taken |
| 631 | // before that would leak and keep the scope from ever completing. |
| 632 | let _ = ScopePtr::new(scope).into_raw(); |
| 633 | |
| 634 | // SAFETY: `JobStorage::as_job_ref` requires: |
| 635 | // |
| 636 | // * That `JobRef::execute` is only called when it is sound to call |
| 637 | // `ScopedJobStorage::<'scope, 'env, T>::execute` on this storage. The |
| 638 | // storage is borrowed for `'scope`, and the scope reference taken |
| 639 | // above keeps the scope (and so `'scope`) from ending until the job |
| 640 | // has run. We hold the claim made above, which records this scope and |
nothing calls this directly
no test coverage detected