pluralsight / PSOperations

A framework for advanced NSOperations usage
https://developer.apple.com/videos/wwdc/2015/?id=226
Apache License 2.0
659 stars 103 forks source link

call cancel() method didn't finish the operation! #83

Open ichagall opened 7 years ago

ichagall commented 7 years ago

for the executing operations , call cancel() don't finish the operation really, the method just mark the operations' state as hasFinished and remove the operations from the queue, in fact these operations are still running.

scottymac commented 7 years ago

@ichagall That is the expected behavior. cancel() just sets the state, but does not itself call finish() -- you have to also do that.

EDIT: Looks like PSOperations works differently from the WWDC Operations project. From what I can tell cancel() does in fact call finish() -- I think this makes more sense.

override open func cancel() {
        stateLock.withCriticalScope {
            if isFinished {
                return
            }

            _cancelled = true

            if state > .ready {
                finish()
            }
        }
    }
priteshshah1983 commented 7 years ago

You should read the discussion in https://github.com/pluralsight/PSOperations/issues/74 as it is relevant