(self: Pin<&mut Self>, cx: &mut Context<'_>)
| 956 | type Output = Result<Option<StoreFiber<'b>>>; |
| 957 | |
| 958 | fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
| 959 | let me = self.get_mut(); |
| 960 | |
| 961 | // SAFETY: We need to carry over this `cx` into our fiber's runtime for |
| 962 | // when it tries to poll sub-futures that are created. Doing this must |
| 963 | // be done unsafely, however, since `cx` is only alive for this one |
| 964 | // singular function call. Here we do a `transmute` to extend the |
| 965 | // lifetime of `Context` so it can be stored in our `Store`, and then we |
| 966 | // replace the current polling context with this one. |
| 967 | // |
| 968 | // The safety of this extension relies on never actually using |
| 969 | // `Context<'static>` with `'static` actually there, which should be |
| 970 | // satisfied by the users of this in the `BlockingContext` structure |
| 971 | // where the lifetime parameters there are always more constrained than |
| 972 | // they are here. |
| 973 | let cx: &mut Context<'static> = unsafe { change_context_lifetime(cx) }; |
| 974 | let cx = NonNull::from(cx); |
| 975 | |
| 976 | match resume_fiber(me.store, me.fiber.as_mut().unwrap(), Ok(cx)) { |
| 977 | Ok(Ok(())) => Poll::Ready(Ok(None)), |
| 978 | Ok(Err(e)) => Poll::Ready(Err(e)), |
| 979 | Err(StoreFiberYield::KeepStore) => Poll::Pending, |
| 980 | #[cfg(feature = "component-model-async")] |
| 981 | Err(StoreFiberYield::ReleaseStore) => match &me.on_release { |
| 982 | OnRelease::ReturnPending => Poll::Pending, |
| 983 | OnRelease::ReturnReady => Poll::Ready(Ok(me.fiber.take())), |
| 984 | }, |
| 985 | } |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | impl Drop for FiberFuture<'_, '_> { |
no test coverage detected