Re: Callbacks from async blocks

2013-03-20 Thread Allan Odgaard
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 currentOp

Re: Callbacks from async blocks

2013-03-19 Thread Roland King
All the code touching that variable is on the main thread. So it's serialized by that. On 16 Mar, 2013, at 23:13, Allan Odgaard 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 oper

Re: Callbacks from async blocks

2013-03-19 Thread Allan Odgaard
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 == cur

Re: Callbacks from async blocks

2013-03-16 Thread Oleg Krupnov
Thanks, Roland. I can see you are comparing the member variable currentOperation of the caller's class and a locally declared variable currentOperationAtQueueTime. Good idea. Obviously, the block retains "self" of the caller object and all local variables referenced from within the block. So when

Re: Callbacks from async blocks

2013-03-16 Thread Roland King
> However, when I use completion blocks instead of delegates, things get > somewhat vague. > > Is it still necessary to store the current operation in a property, or > does each operation get its own independent copy of the completion > block, together with its current context? What happens if I

Callbacks from async blocks

2013-03-16 Thread Oleg Krupnov
I want to switch to blocks instead of delegates for small callbacks, e.g. operationDidFinish or animationDidFinish, but there is a question I cannot understand. There is the typical scenario when I need to run an operation (usually in another thread) and while it is running, I should ignore new re