Question d’entretien chez Uber

Implement async task dispatcher with ability to cancel tasks, using GCD internally.

Réponses aux questions d'entretien

Utilisateur anonyme

24 juin 2019

NSOperations use GCD “internally”, I wonder if setting that up would have been an acceptable answer, since it already has cancel? Probably not, they probably want the implementation.

Utilisateur anonyme

30 oct. 2017

We can create a class DispatchCancelTask with a cancel property and static method with return type as the class. Parameters to the method can be the queue, type, and completion handler as closure with void input and return type, check for is canceled property before executing the closure.