-
-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start ImageTask in .suspended state #844
Conversation
@@ -152,26 +151,33 @@ public final class ImageTask: Hashable { | |||
self.isDataTask = isDataTask | |||
self.pipeline = pipeline | |||
self.onEvent = onEvent | |||
// TODO: remove thread hop | |||
self.task = Task { @ImagePipelineActor in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ImageTask
is created from a nonisolated
method (by design), which previously required to spawn a Task
to perform it. By delaying the task start until you call one of its async
APIs such as response: ImageResponse
, we can take advantage of the asynchronous context created by however invokes it. There is no need to spawn one of our own. This eliminates a thread hop.
/// The task is currently running. | ||
case running | ||
/// The task has received a cancel message. | ||
case cancelled | ||
/// The task has completed (without being canceled). | ||
case completed | ||
case completed(Result<ImageResponse, Error>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It no longer relies on Task
caching of results.
No description provided.