[quote='783226021, billh04, /thread/783226, /profile/billh04'] How can you force cancel a task that … doesn't check for cancellation? [/quote] You can’t. [quote='783226021, billh04, /thread/783226, /profile/billh04'] would this be a useful addition to Swift? [/quote] Unlikely. You’re reasoning from a false premise here. All meaningful Swift functions require some sort of cleanup. The fact that this cleanup isn’t obvious is just the compiler hiding fiddly implementation details from you. A classic example of this is ARC, where you don’t have to worry about cleaning up because the compiler is emitting all the necessary retains and releases. Given that reality, there’s no way to stop code that doesn’t check for cancellation. Attempting to do that would leave the program in an undefined state. For example, a valid implementation of malloc would be: Lock a mutex that protects the memory allocator’s state. Manipulate that state to allocate the memory. Unlock the mutex. Return that pointer from step 2. If your task
Topic:
App & System Services
SubTopic:
Processes & Concurrency
Tags: