PSOperations icon indicating copy to clipboard operation
PSOperations copied to clipboard

cancel should not call finish, should it?

Open t089 opened this issue 9 years ago • 7 comments

I am a bit surprised to see that the cancel implementation of Operation calls finish by itself, if state > .Ready. Shouldn't cancel only mark the operation as cancelled ? Isn't it the responsibility of the operation to check for this flag, and if true, stop its work, clean up and only then transition to the finished state? Or am I missing something?

t089 avatar Aug 12 '16 07:08 t089

Yeah, I struggled with this a bit myself. Especially when using group operations and dealing with race conditions.

If you haven't seen my reported issue I would like to hear other's thoughts on it. Shameless plug for advice :D

https://github.com/pluralsight/PSOperations/issues/69

jcarroll-mediafly avatar Aug 12 '16 14:08 jcarroll-mediafly

@t089 I agree. This was pointed out quite a while ago too. One of the reasons we haven't changed it yet is that it's a pretty big breaking change.

MarkQSchultz avatar Aug 12 '16 16:08 MarkQSchultz

Ok, well I guess it is a big change, but it is also quite a big mistake in the implementation. In its current form a call to cancel will immediately fire the completion observers and clients would think that the op finished its work, while in reality it might still be very busy and do stuff. Even worse, when it is done it can't call the didFinish observer again because it already fired.

t089 avatar Aug 12 '16 17:08 t089

You do realize that I already said that I agree with you, right? Not sure the point of most of that comment...

MarkQSchultz avatar Aug 12 '16 17:08 MarkQSchultz

Yup just wanted to add some more arguments pro change. Sorry if you feel it was redundant.

You do realize that I already said that I agree with you, right? Not sure the point of most of that comment...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

t089 avatar Aug 12 '16 17:08 t089

👍This would be a good change. Just a big one at this point. That's all. I would want to version the framework on this change though, as it is a breaking change.

MarkQSchultz avatar Aug 12 '16 17:08 MarkQSchultz

It doesn't look like this change was ever made (or merged). Can you please confirm?

priteshshah1983 avatar Jun 17 '17 05:06 priteshshah1983