[swift-corelibs-dev] Asynchronous Operations

Ian Partridge ipartridge at gmail.com
Wed Jan 25 07:01:58 CST 2017

Thank you everyone for your comments.

Adding willChangeValue(forKey:) and didChangeValue(forKey:) to
Operation does solve the problem for me.  The Swift 3 code I'm porting
from macOS to Linux works correctly when I patch Foundation as Brent

I've opened a PR against swift-corelibs-foundation and would welcome
feedback on this.  Thank you.


P.S. The code I'm porting is roughly analogous to
although it uses URLSession instead of an async dispatch queue.

On 23 January 2017 at 17:32, Tony Parker <anthony.parker at apple.com> wrote:
> Hm, that’s probably the least bad option we have at the moment.
> I don’t want to introduce “new” API, as it is unlikely we will be able to remove it when whatever permanent solution comes up.
> - Tony
>> On Jan 21, 2017, at 6:09 AM, Brent Royal-Gordon via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
>>> On Jan 20, 2017, at 7:55 AM, Ian Partridge via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
>>> Is there any way that we could support asynchronous operations in swift-corelibs-foundation, in the absence of KVO?
>> Could we add `willChangeValue(forKey:)` and `didChangeValue(forKey:)` methods just to `Operation` which only handle an `isFinished` key? Presumably they'd just look like:
>>       public func willChangeValue(forKey key: String) {
>>               // do nothing
>>       }
>>       public func didChangeValue(forKey key: String) {
>>               if key == "isFinished" && isFinished {
>>                       finish()
>>               }
>>       }
>> I believe that would make existing code just work without needing to do anything special.
>> --
>> Brent Royal-Gordon
>> Architechies
>> _______________________________________________
>> swift-corelibs-dev mailing list
>> swift-corelibs-dev at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

Ian Partridge

More information about the swift-corelibs-dev mailing list