On 20 Mar 2013, at 4:28, Roland King wrote:

All the code touching that variable is on the main thread. So it's serialized by that.

Say you start block A (slow) and block B (fast).

Now block B calls main queue and we have ‘currentOperation == currentOperationAtQueueTime’ so we reset currentOperation to zero.

Then we fire block C and block A returns.

currentOperation is at 1 and currentOperationAtQueueTime for block A was 1, so we accept the result from A and reset currentOperation again.

Now block C finish, but its result is not accepted, since currentOperation is 0 and block C wants 1.

So where we should have ignored block A and accepted B and then C, we instead accept block B, A and ignore block C.

On 16 Mar, 2013, at 23:13, Allan Odgaard <lists+cocoa-...@simplit.com> wrote:

On 16 Mar 2013, at 14:14, Roland King wrote:

[…] you have a simple counter member variable, 'currentOperation'. It's set to 0 when you have no operation and you increment it each time you make a new one. The code looks like this (typed in mail) […]

if( currentOperation == currentOperationAtQueueTime )
{
    [ yourClass operationDidFinish ];
    currentOperation = 0;
}

Correct me if I’m wrong, but you can only set ‘currentOperation’ to zero if it’s a serial queue or you know it’s empty.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org

This email sent to r...@rols.org
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to