Daily iOS
Concurrency

Structured cancellation

When the search query changes, the previous search's network, decoding, and image work all have to stop. How would you structure the task tree using cancellation propagation from parent Task to child Tasks?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Map one search to one parent Task and structure the network, decoding, and image work as child Tasks inside it; then when the query changes, calling cancel() on the one parent Task you kept propagates cancellation to every child.

Share a question