[swift-corelibs-dev] Cancelable DispatchQueue.concurrentPerform
Karl Wagner
razielim at gmail.com
Thu Feb 23 10:35:27 CST 2017
Would it be possible to make a cancelable version of DispatchQueue.concurrentPerform, allowing you to abort any yet-to-be-scheduled blocks?
The use-case is for when you’re concurrently performing a job and one of them sets a flag or fails in a way which already defines the result. Further execution wouldn’t affect the outcome, so it would be nice if an operation could flag back to concurrentPerform that it doesn’t have to schedule any more jobs.
For a real-world example, see this concurrent RandomAccessCollection wrapper I was building: https://gist.github.com/karwa/43ae838809cc68d317003f2885c71572 <https://gist.github.com/karwa/43ae838809cc68d317003f2885c71572>
It would be beneficial if we could stop early in the case of errors (see: _forEach), or if some global flag is set (see: contains).
- Karl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20170223/3dc8e01b/attachment.html>
More information about the swift-corelibs-dev
mailing list