Re: Using alarm(3) on background NSOperationQueue threads

2015-08-21 Thread Carl Hoefs
> On Aug 20, 2015, at 5:55 PM, Ken Thomases wrote: > > On Aug 20, 2015, at 7:29 PM, Carl Hoefs > wrote: >> >> From within a background NSOperationQueue thread, the effects of alarm(3) >> seem to be ignored. (I use alarm() to interrupt certain system calls like

Re: Using alarm(3) on background NSOperationQueue threads

2015-08-20 Thread Ken Thomases
On Aug 20, 2015, at 7:29 PM, Carl Hoefs wrote: > > From within a background NSOperationQueue thread, the effects of alarm(3) > seem to be ignored. (I use alarm() to interrupt certain system calls like > connect() when they stall.) The alarm fires, the alarm handler is invoked

Using alarm(3) on background NSOperationQueue threads

2015-08-20 Thread Carl Hoefs
From within a background NSOperationQueue thread, the effects of alarm(3) seem to be ignored. (I use alarm() to interrupt certain system calls like connect() when they stall.) The alarm fires, the alarm handler is invoked, but the ongoing sys call is not interrupted, as it would be normally. Is

Re: Recurrent NSInvocationOperations on an NSOperationQueue?

2015-08-14 Thread Carl Hoefs
> On Aug 14, 2015, at 7:01 PM, Ken Thomases wrote: > > On Aug 14, 2015, at 8:43 PM, Carl Hoefs > wrote: > > You can use a serial GCD queue for the same purpose with my above > suggestions. But even if you want to keep using an NSOperationQueue, you can > still use

Re: Recurrent NSInvocationOperations on an NSOperationQueue?

2015-08-14 Thread Roland King
e status checks. So I have an NSOperationQueue > that has maxConcurrentOperationCount set to 1, but I need a status-check > operation to be automatically queued up 1 minute after the last one has run. > > So, if the device is accessed otherwise the status checks won't interfere

Re: Recurrent NSInvocationOperations on an NSOperationQueue?

2015-08-14 Thread Ken Thomases
On Aug 14, 2015, at 8:43 PM, Carl Hoefs wrote: > On Aug 14, 2015, at 6:24 PM, Ken Thomases wrote: >> >> -performSelector:withObject:afterDelay: depends on the run loop. The >> threads that service any non-main NSOperationQueue don't run their run loop. >>

Re: Recurrent NSInvocationOperations on an NSOperationQueue?

2015-08-14 Thread Carl Hoefs
withObject:nil >> afterDelay:60.0]; // <-- This never fires! >> >> [self doStatusChecks]; // <-- Fires immediately, but not what I want >> } > > -performSelector:withObject:afterDelay: depends on the run loop. The threads > that service any non-main NSOperationQu

Re: Recurrent NSInvocationOperations on an NSOperationQueue?

2015-08-14 Thread Ken Thomases
rmSelector:withObject:afterDelay: depends on the run loop. The threads that service any non-main NSOperationQueue don't run their run loop. In fact, you can't rely on them surviving past the end of your operation's code returning. You will need to shunt this to a threa

Re: Recurrent NSInvocationOperations on an NSOperationQueue?

2015-08-14 Thread Carl Hoefs
> On Aug 14, 2015, at 5:46 PM, Carl Hoefs > wrote: > > >> On Aug 14, 2015, at 4:15 PM, Ken Thomases wrote: >> >> You'll need to create a new operation each time you want to queue a >> particular invocation. > > Yes, I'm doing that. The problem is finding a mechanism to re-queue a new > op

Re: Recurrent NSInvocationOperations on an NSOperationQueue?

2015-08-14 Thread Carl Hoefs
> On Aug 14, 2015, at 4:15 PM, Ken Thomases wrote: > > You'll need to create a new operation each time you want to queue a > particular invocation. Yes, I'm doing that. The problem is finding a mechanism to re-queue a new operation from the current one after it is done, so the queue can be em

Re: Recurrent NSInvocationOperations on an NSOperationQueue?

2015-08-14 Thread Ken Thomases
On Aug 14, 2015, at 5:23 PM, Carl Hoefs wrote: > I'm trying to automatically re-queue an NSInvocationOperation to an > NSOperationQueue every n seconds, but I can't get it to work. From the NSOperation class overview: "An operation object is a single-shot object—that is,

Recurrent NSInvocationOperations on an NSOperationQueue?

2015-08-14 Thread Carl Hoefs
I'm trying to automatically re-queue an NSInvocationOperation to an NSOperationQueue every n seconds, but I can't get it to work. For the purpose of serializing exclusive access to a specific resource, I have a single-threaded background NSOperationQueue with

Re: How to perform delayed calls using NSOperationQueue?

2014-07-21 Thread Kyle Sluder
On Mon, Jul 21, 2014, at 08:03 PM, Jens Alfke wrote: > > On Jul 21, 2014, at 5:54 PM, Cody Garvin wrote: > > > I ended up writing a queue manager that took NSOperations along with times, > > preflight block check and postflight block (setting other things up, > > massaging, etc). > > Really,

Re: How to perform delayed calls using NSOperationQueue?

2014-07-21 Thread Roland King
was going to be > straightforward, until I saw that NSURLSession only supports scheduling > delegate calls on an NSOperationQueue, not an NSRunLoop. So that means I now > also have to convert a number of runloop dependencies in the same code, which > I don’t understand how to do. > >

Re: How to perform delayed calls using NSOperationQueue?

2014-07-21 Thread Cody Garvin
I'd love to be wrong. Hopefully I am. Please excuse mobile typos > On Jul 21, 2014, at 6:03 PM, Jens Alfke wrote: > > >> On Jul 21, 2014, at 5:54 PM, Cody Garvin wrote: >> >> I ended up writing a queue manager that took NSOperations along with times, >> preflight block check and postflight

Re: How to perform delayed calls using NSOperationQueue?

2014-07-21 Thread Jens Alfke
On Jul 21, 2014, at 5:54 PM, Cody Garvin wrote: > I ended up writing a queue manager that took NSOperations along with times, > preflight block check and postflight block (setting other things up, > massaging, etc). Really, we have to reinvent NSTimer ourselves? Especially after Apple optimiz

Re: How to perform delayed calls using NSOperationQueue?

2014-07-21 Thread Cody Garvin
I know it’s not NSOperationQueue but GCD has dispatch_after. I ended up writing a queue manager that took NSOperations along with times, preflight block check and postflight block (setting other things up, massaging, etc). I don’t thinkw NSOperationQueue has an equivalent. Could be wrong

How to perform delayed calls using NSOperationQueue?

2014-07-21 Thread Jens Alfke
scheduling delegate calls on an NSOperationQueue, not an NSRunLoop. So that means I now also have to convert a number of runloop dependencies in the same code, which I don’t understand how to do. Case in point: I have a couple of things that require the use of delayed performs to schedule timing

Re: iOS - NSOperation/NSOperationQueue Question

2014-06-04 Thread Dave
mediately >>>> and the Delegate is called when the operation completes or fails. >>>> >>>> This all works, however I have some existing code that I’d like to have >>>> the same API and be called by a “Manager Class” which calls the correct >>

Re: iOS - NSOperation/NSOperationQueue Question

2014-06-03 Thread Jeffrey Robert Kelley
>> >>> This all works, however I have some existing code that I’d like to have the >>> same API and be called by a “Manager Class” which calls the correct >>> underlying API depending on the context, e.g. >>> >>> AppLayer—>ManagerClass—>API_A >>>

Re: iOS - NSOperation/NSOperationQueue Question

2014-06-03 Thread Dave
context, e.g. >> >> AppLayer—>ManagerClass—>API_A >>—>API_B >> >> API_A is the existing API supporting the Sync/Async interface. >> API_B is the one I wish to create. >> >> The problem is that the exist

Re: iOS - NSOperation/NSOperationQueue Question

2014-06-03 Thread Jeffrey Robert Kelley
API_B > > API_A is the existing API supporting the Sync/Async interface. > API_B is the one I wish to create. > > The problem is that the existing code uses NSOperationQueue/NSOperation > accomplish it’s task, this works fine in Async mode, it was easy enough to > adapt to call t

iOS - NSOperation/NSOperationQueue Question

2014-06-03 Thread Dave
rting the Sync/Async interface. API_B is the one I wish to create. The problem is that the existing code uses NSOperationQueue/NSOperation accomplish it’s task, this works fine in Async mode, it was easy enough to adapt to call the Delegate methods, but I’m not sure how to implement Sync mode?

Re: Synchronous Serial Port Protocol messaging With NSOperationQueue/GCD

2013-08-07 Thread Vanni Parronchi
Hi all, Thank you all for you contribution and responses. It was my first message to the list and was a bit intimidated :). the app is meant to be modular, 10.7 based and it has to manage not only serial devices (rs485) but also USB ones (through a virtual com port using an FTDI chip on the devic

Re: Synchronous Serial Port Protocol messaging With NSOperationQueue/GCD

2013-08-07 Thread Ken Thomases
On Aug 7, 2013, at 2:20 AM, Tom Davie wrote: > My suggestion would instead be to make an NSOperation subclass for sending a > message to the device. > > That subclass should require you to specify to which device you are talking. > Each device object should carry around a dispatch_semaphore.

Re: Synchronous Serial Port Protocol messaging With NSOperationQueue/GCD

2013-08-07 Thread Sean McBride
On Thu, 1 Aug 2013 12:03:01 +0200, Vanni Parronchi said: >hi everyone, > >I'm writing a mac osx app that needs to talk to a serial device. Have you considered using the open source AMSerialPort class? It doesn't use GCD, but does have an NSThread option. It could probably be retrofitted to use

Re: Synchronous Serial Port Protocol messaging With NSOperationQueue/GCD

2013-08-07 Thread Tom Davie
'm trying to keep the UI free so i'm doing > all the messaging stuff on background threads. My choice is to use > NSOperation and NSOperationQueue, where the queue is configured with > maxConcurrentOperations set to 1 in order to have a strict serial behavior > (this is due to t

Synchronous Serial Port Protocol messaging With NSOperationQueue/GCD

2013-08-07 Thread Vanni Parronchi
ice is to use NSOperation and NSOperationQueue, where the queue is configured with maxConcurrentOperations set to 1 in order to have a strict serial behavior (this is due to the constraints given by the implemented protocol). How can i make an NSOperation subclass waiting for a signal given by the ser

Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)

2013-02-05 Thread Steve Sisak
At 8:13 AM -0800 2/5/13, Glenn L. Austin wrote: I understand the *reasoning* behind performSelector:withObject:afterDelay:, but I've banned that from code I work on. In the OP's case, I think he just needs to perform the selector asynchronously so he doesn't deadlock -- waitUntilDone:NO ought

Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)

2013-02-05 Thread Glenn L. Austin
On Feb 4, 2013, at 8:58 AM, Kyle Sluder wrote: > On Sun, Feb 3, 2013, at 11:58 PM, 尹佳冀 wrote: >> Thanks Mike seem You are right, and I write like this >> >> [self performSelector:@selector(doTheThing) withObject:nil >> afterDelay:0.5]; >> it can work correctly. > > Magic constants like this ar

Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)

2013-02-04 Thread Steve Sisak
At 3:58 PM +0800 2/4/13, õöâ¿ôb wrote: Thanks Mike seem You are right, and I write like this [self performSelector:@selector(doTheThing) withObject:nil afterDelay:0.5]; it can work correctly. And thanks for your suggestion I suspect that if you change > >//Case 3 hang up, HUD not s

Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)

2013-02-04 Thread Kyle Sluder
On Sun, Feb 3, 2013, at 11:58 PM, 尹佳冀 wrote: > Thanks Mike seem You are right, and I write like this > > [self performSelector:@selector(doTheThing) withObject:nil > afterDelay:0.5]; > it can work correctly. Magic constants like this are evil and are a serious indicator of poor programming practi

Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)

2013-02-04 Thread 尹佳冀
; > Does anyone can know what the difference between [NSOperationQueue > > currentQueue] and > > performSelectorOnMainThread, If I do some work use operation > > on [NSOperationQueue mainQueue], the UI will not hang up, but if i > > use performSelectorOnMainThr

Re: What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)

2013-02-03 Thread Mike Abdullah
On 3 Feb 2013, at 07:41, 尹佳冀 wrote: > Hi All > > Does anyone can know what the difference between [NSOperationQueue > currentQueue] and > performSelectorOnMainThread, If I do some work use operation > on [NSOperationQueue mainQueue], the UI will not hang

What's the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread (iOS platform)

2013-02-02 Thread 尹佳冀
Hi All Does anyone can know what the difference between [NSOperationQueue currentQueue] and performSelectorOnMainThread, If I do some work use operation on [NSOperationQueue mainQueue], the UI will not hang up, but if i use performSelectorOnMainThread the UI will hang up - (void) doTheThing

Re: NSOperationQueue and for-loop

2012-10-03 Thread Mike Abdullah
On 3 Oct 2012, at 14:17, Koen van der Drift wrote: > On Wed, Oct 3, 2012 at 9:03 AM, Koen van der Drift > wrote: > Good point, thanks. So are there any workarounds for that? I'm sure >> this pattern (doing lots of calculations concurrently, and store the >> results in a common object for later)

Re: NSOperationQueue and for-loop

2012-10-03 Thread Koen van der Drift
On Wed, Oct 3, 2012 at 9:03 AM, Koen van der Drift wrote: Good point, thanks. So are there any workarounds for that? I'm sure > this pattern (doing lots of calculations concurrently, and store the > results in a common object for later), is used in other situations as > well. >From a quick search

Re: NSOperationQueue and for-loop

2012-10-03 Thread Koen van der Drift
On Wed, Oct 3, 2012 at 8:48 AM, Mike Abdullah wrote: > Regardless, your posted code is going to blow up sooner or later. NSMutableArray is not safe to modify from more than a single thread at a time. If two of your worker blocks happen to finish at the same time and call -addObject: together, nast

Re: NSOperationQueue and for-loop

2012-10-03 Thread Mike Abdullah
; > NSUInteger __block i, j,; > MyObject __block *newObj; > > NSMutabbleArray*temp = [[NSMutableArray alloc] init]; > NSOperationQueue *q = [[NSOperationQueue alloc] init]; > > for (i = 0; i < 10; i++) { > [q addOperationWithBlock: ^{ >

Re: NSOperationQueue and for-loop

2012-10-03 Thread Koen van der Drift
daytime job), but I think I know what could be going on. This is some code (typed in email program) very similar to what I did so far and which was causing the crashes: NSUInteger __block i, j,; MyObject __block *newObj; NSMutabbleArray *temp = [[NSMutableArray alloc] init]; NSOperationQueue *q =

Re: NSOperationQueue and for-loop

2012-10-02 Thread Koen van der Drift
On Oct 2, 2012, at 9:21 PM, davel...@mac.com wrote: > Only variables that are being modified by the block need to be declared with > the __block specifier. You shouldn't be declaring the underlying instance > variables as __block. You can mix and match ARC and non-ARC code. Google > should hel

Re: NSOperationQueue and for-loop

2012-10-02 Thread davelist
On Oct 2, 2012, at 8:43 PM, Koen van der Drift wrote: > > On Oct 2, 2012, at 6:19 PM, Koen van der Drift > wrote: > >> >> On Oct 2, 2012, at 6:07 PM, davel...@mac.com wrote: >> >>> I can't speak to the other examples since I haven't seen them, but the >>> __block specifier is necessary i

Re: NSOperationQueue and for-loop

2012-10-02 Thread Koen van der Drift
On Oct 2, 2012, at 6:19 PM, Koen van der Drift wrote: > > On Oct 2, 2012, at 6:07 PM, davel...@mac.com wrote: > >> I can't speak to the other examples since I haven't seen them, but the >> __block specifier is necessary if your block modifies the variable (your >> block does modify i). Your

Re: NSOperationQueue and for-loop

2012-10-02 Thread Koen van der Drift
On Oct 2, 2012, at 6:07 PM, davel...@mac.com wrote: > I can't speak to the other examples since I haven't seen them, but the > __block specifier is necessary if your block modifies the variable (your > block does modify i). Your example also seems a bit strange since your for > loop modifies i

Re: NSOperationQueue and for-loop

2012-10-02 Thread davelist
On Oct 2, 2012, at 5:49 PM, Koen van der Drift wrote: > Hi, > > When looking how to implement an NSOperationQueue with a loop, I found > several examples that have the following structure: > > NSInteger i; > >for ( i = 0; i < 1000; i++

NSOperationQueue and for-loop

2012-10-02 Thread Koen van der Drift
Hi, When looking how to implement an NSOperationQueue with a loop, I found several examples that have the following structure: NSInteger i; for ( i = 0; i < 1000; i++ ) { [queue addOperationWithBlock:^{ i +

Re: NSOperationQueue

2012-06-03 Thread Graham Cox
Right now, what I actually do is to hold the operations in a queue of my own, and only feed them to the actual NSOperationQueue when a timer fires and the queue has some capacity. At that point I am able to reprioritise the pending operations (including those already queued but not yet executing

Re: NSOperationQueue

2012-06-03 Thread Charles Srstka
On Jun 3, 2012, at 1:23 AM, Graham Cox wrote: > define "the visible objects" when what you have at hand is not a visual > object at all, but an object whose job is to make an image from some data. I’ll go with whatever you meant when you said: On Jun 2, 2012, at 12:34 AM, Graham Cox wrote: >

Re: NSOperationQueue

2012-06-03 Thread Graham Cox
On 03/06/2012, at 4:54 PM, Kyle Sluder wrote: > If IKImageView's architecture is proving to be a problem, perhaps it's time > to consider ditching IKImageView. I'm certainly going to give that some serious thought. In fact my scheme is now working fairly well, at least when I run it from Xcod

Re: NSOperationQueue

2012-06-02 Thread Kyle Sluder
On Jun 2, 2012, at 11:23 PM, Graham Cox wrote: > > define "the visible objects" when what you have at hand is not a visual > object at all, but an object whose job is to make an image from some data If IKImageView's architecture is proving to be a problem, perhaps it's time to consider ditchi

Re: NSOperationQueue

2012-06-02 Thread Graham Cox
On 03/06/2012, at 4:13 PM, Charles Srstka wrote: > On Jun 2, 2012, at 8:16 PM, Graham Cox wrote: > >> The problem is not that setting the priority of an operation doesn't work, >> it's that manipulating the priority based on what is visible at a given >> moment is hard. > > How is it hard? Yo

Re: NSOperationQueue

2012-06-02 Thread Charles Srstka
On Jun 2, 2012, at 8:16 PM, Graham Cox wrote: > The problem is not that setting the priority of an operation doesn't work, > it's that manipulating the priority based on what is visible at a given > moment is hard. How is it hard? You just call setQueuePriority: on the operations for the visib

Re: NSOperationQueue

2012-06-02 Thread Graham Cox
On 03/06/2012, at 3:03 AM, Ken Thomases wrote: > That said, I don't know that OP requires strict LIFO order. He just wants > the operations associated with images which are scrolled into view to have > higher priority than those which aren't. That can just be accomplished by > setting the pr

Re: NSOperationQueue

2012-06-02 Thread Charles Srstka
On Jun 2, 2012, at 12:32 PM, Markus Spoettl wrote: >> Who said anything about order? > > The OP did: > >> Is there a way to add operations to the queue so that they "jump the queue" >> ahead of any operations that are not running and have not been run yet? That statement isn’t expressing a des

Re: NSOperationQueue

2012-06-02 Thread Markus Spoettl
On 6/2/12 7:27 PM, Kyle Sluder wrote: On Jun 2, 2012, at 9:54 AM, Markus Spoettl wrote: I'm still not seeing how queuePriority would solve the issue. Say you have a queue with maxConcurrentOperationCount == 1 OP expressed his desire to have a queue with maxConcurrentOperationCount> 1. W

Re: NSOperationQueue

2012-06-02 Thread Charles Srstka
On Jun 2, 2012, at 11:54 AM, Markus Spoettl wrote: > I'm still not seeing how queuePriority would solve the issue. Say you have a > queue with maxConcurrentOperationCount == 1 > > 1) You add operation (A), it starts executing > > 2) You add operation (B), (C), (D), (E), (F), (G), (H) and (I) in

Re: NSOperationQueue

2012-06-02 Thread Kyle Sluder
On Jun 2, 2012, at 9:54 AM, Markus Spoettl wrote: > > I'm still not seeing how queuePriority would solve the issue. Say you have a > queue with maxConcurrentOperationCount == 1 OP expressed his desire to have a queue with maxConcurrentOperationCount > 1. > > Please explain how you suggest to

Re: NSOperationQueue

2012-06-02 Thread Charles Srstka
On Jun 2, 2012, at 11:54 AM, Markus Spoettl wrote: > I'm still not seeing how queuePriority would solve the issue. Say you have a > queue with maxConcurrentOperationCount == 1 > > 1) You add operation (A), it starts executing > > 2) You add operation (B), (C), (D), (E), (F), (G), (H) and (I) in

Re: NSOperationQueue

2012-06-02 Thread Ken Thomases
On Jun 2, 2012, at 11:54 AM, Markus Spoettl wrote: > I'm still not seeing how queuePriority would solve the issue. Say you have a > queue with maxConcurrentOperationCount == 1 > > 1) You add operation (A), it starts executing > > 2) You add operation (B), (C), (D), (E), (F), (G), (H) and (I) in

Re: NSOperationQueue

2012-06-02 Thread Markus Spoettl
priorities as the user scrolls, and NSOperationQueue will do the right thing. I tried this but it doesn't work - a bit of thought about how the ops are queued will show why no meaningful priority value can be assigned. At the moment that the operations are queued, there are some operations i

Re: NSOperationQueue

2012-06-02 Thread Kyle Sluder
On Jun 2, 2012, at 9:04 AM, Charles Srstka wrote: > > It’s even easier than that, since there’s no need to de-prioritize anything. > You just have everything’s priority set to NSOperationQueuePriorityNormal at > the time of enqueuing, and give NSOperationQueuePriorityHigh or > NSOperationQueu

Re: NSOperationQueue

2012-06-02 Thread Charles Srstka
e: >>>> >>>>> Give them a higher priority. You should be able to alter the priorities >>>>> as the user scrolls, and NSOperationQueue will do the right thing. >>>> >>>> >>>> I tried this but it doesn't work - a bi

Re: NSOperationQueue

2012-06-02 Thread Kyle Sluder
ble to alter the priorities as >>>> the user scrolls, and NSOperationQueue will do the right thing. >>> >>> >>> I tried this but it doesn't work - a bit of thought about how the ops are >>> queued will show why no meaningful priority value ca

Re: NSOperationQueue

2012-06-02 Thread Markus Spoettl
On 6/2/12 4:57 PM, Charles Srstka wrote: On Jun 1, 2012, at 10:23 PM, Graham Cox wrote: On 02/06/2012, at 1:12 PM, Kyle Sluder wrote: Give them a higher priority. You should be able to alter the priorities as the user scrolls, and NSOperationQueue will do the right thing. I tried this

Re: NSOperationQueue

2012-06-02 Thread Charles Srstka
On Jun 1, 2012, at 10:23 PM, Graham Cox wrote: > On 02/06/2012, at 1:12 PM, Kyle Sluder wrote: > >> Give them a higher priority. You should be able to alter the priorities as >> the user scrolls, and NSOperationQueue will do the right thing. > > > I tried this but

Re: NSOperationQueue

2012-06-01 Thread Graham Cox
On 02/06/2012, at 2:36 PM, Julius Oklamcak wrote: > Potentially you could end up queuing up hundreds (or thousands) of thumbnail > generation requests (depending on how many SVG files the user has). If the > user was to close the browser to do something else, or switch to another > app, you would

RE: NSOperationQueue

2012-06-01 Thread Julius Oklamcak
>> At the moment that the operations are queued, there are some operations in the queue not yet run, and some running. The code that creates the operations doesn't know which ones are needed more urgently (the latest ones), so it can only assign a high priority to all of them, so they all end up wi

Re: NSOperationQueue

2012-06-01 Thread Kyle Sluder
On Jun 1, 2012, at 8:23 PM, Graham Cox wrote: > > On 02/06/2012, at 1:12 PM, Kyle Sluder wrote: > >> Give them a higher priority. You should be able to alter the priorities as >> the user scrolls, and NSOperationQueue will do the right thing. > > > I tried th

Re: NSOperationQueue

2012-06-01 Thread Graham Cox
On 02/06/2012, at 1:12 PM, Kyle Sluder wrote: > Give them a higher priority. You should be able to alter the priorities as > the user scrolls, and NSOperationQueue will do the right thing. I tried this but it doesn't work - a bit of thought about how the ops are queued will

Re: NSOperationQueue

2012-06-01 Thread Kyle Sluder
On Jun 1, 2012, at 8:07 PM, Graham Cox wrote: > A question about NSOperationQueue: > > Is there a way to add operations to the queue so that they "jump the queue" > ahead of any operations that are not running and have not been run yet? Give them a higher priority. You s

NSOperationQueue

2012-06-01 Thread Graham Cox
A question about NSOperationQueue: Is there a way to add operations to the queue so that they "jump the queue" ahead of any operations that are not running and have not been run yet? Here's my use case: I have a browser that browses folders full of SVG files. To create a thumbn

Re: receptionist pattern question: NSOperationQueue vs. GCD

2012-02-16 Thread Matt Neuburg
On Feb 16, 2012, at 9:34 AM, Kyle Sluder wrote: > I must correct myself: NSOperationQueue uses GCD on iOS 4 and higher Good; I thought so, but you made me doubt it... :) m. -- matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/ pantes anthropoi tou eidenai oregontai phu

Re: receptionist pattern question: NSOperationQueue vs. GCD

2012-02-16 Thread Kyle Sluder
On Feb 16, 2012, at 8:09 AM, Matt Neuburg wrote: > On Wed, 15 Feb 2012 13:56:14 -0800, Kyle Sluder said: >> >> On iOS, NSOperationQueue doesn't use GCD at all. On Mac OS X 10.6 and >> greater, block-based NSOperations are submitted to global >> (asynchronous)

RE: receptionist pattern question: NSOperationQueue vs. GCD

2012-02-16 Thread Julius Oklamcak
> On iOS, NSOperationQueue doesn't use GCD at all. Actually, posts by Apple people in the Developer Forums and the documentation differs on this: http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/NSOper ationQueue_class/Reference/Reference.html "Note: In iO

Re: receptionist pattern question: NSOperationQueue vs. GCD

2012-02-16 Thread Matt Neuburg
) >> and call dispatch_asynch? Putting it even more generally (and this is >> probably my *real* question), is there any reason why I'd ever use >> NSOperationQueue's addOperationWithBlock given the existence of GCD? > >NSOperationQueue exists at a higher concep

Re: receptionist pattern question: NSOperationQueue vs. GCD

2012-02-15 Thread Preston Sumner
On Feb 15, 2012, at 12:32 PM, Matt Neuburg wrote: > This might be another way of phrasing the same question: why does the new iOS > 5 method +[NSURLConnection sendAsynchronousRequest:queue:completionHandler:] > want an NSOperationQueue as its queue rather than a dispatch queue? m. In

Re: receptionist pattern question: NSOperationQueue vs. GCD

2012-02-15 Thread Kyle Sluder
(and this is > probably my *real* question), is there any reason why I'd ever use > NSOperationQueue's addOperationWithBlock given the existence of GCD? NSOperationQueue exists at a higher conceptual level than GCD. You can observe the status of NSOperations, add completion ha

Re: receptionist pattern question: NSOperationQueue vs. GCD

2012-02-15 Thread Mike Abdullah
Because it's a higher-level API answers pretty much all your questions. You have a little more easy flexibility with what you can do to an NSOperationQueue compared to raw GCD. To put it another way, what downside are you seeing to using NSOperationQueue? On 15 Feb 2012, at 19:32, Matt Ne

Re: receptionist pattern question: NSOperationQueue vs. GCD

2012-02-15 Thread Matt Neuburg
On Feb 15, 2012, at 12:53 PM, Sean McBride wrote: > Apple's always saying to use the highest level API available We must be watching different versions of the WWDC videos... :))) Backwards compatibility is a good reason on the desktop, but I'm on iOS and on iOS if you've got blocks you've got

Re: receptionist pattern question: NSOperationQueue vs. GCD

2012-02-15 Thread Sean McBride
and >this is probably my *real* question), is there any reason why I'd ever >use NSOperationQueue's addOperationWithBlock given the existence of GCD? NSOperationQueue is higher level, and Apple's always saying to use the highest level API available. Another minor reason: NSOperati

Re: receptionist pattern question: NSOperationQueue vs. GCD

2012-02-15 Thread Seth Willits
7;s any difference in this example. > Putting it even more generally (and this is probably my *real* question), is > there any reason why I'd ever use NSOperationQueue's addOperationWithBlock > given the existence of GCD? NSOperationQueue has support for dependencies between oper

Re: receptionist pattern question: NSOperationQueue vs. GCD

2012-02-15 Thread Matt Neuburg
This might be another way of phrasing the same question: why does the new iOS 5 method +[NSURLConnection sendAsynchronousRequest:queue:completionHandler:] want an NSOperationQueue as its queue rather than a dispatch queue? m. -- matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt

receptionist pattern question: NSOperationQueue vs. GCD

2012-02-15 Thread Matt Neuburg
[queue addOperationWithBlock:^{ task(keyPath, object, change); }]; } https://developer.apple.com/library/mac/#documentation/General/Conceptual/CocoaEncyclopedia/ReceptionistPattern/ReceptionistPattern.html Typically, "queue" is [NSOperationQueue mainQueue], our goal being to get o

Good ways to debug a deadlock (NSOperationQueue at __spin_lock)?

2011-11-14 Thread Rico
e app does just before the problem happens: The app creates thumbnail images for files in various folders (via QLThumbnailImageCreate), resizes the images, and displays them. Each thumbnail image is created in a block executed by a single NSOperationQueue instance (concurrently). Looking at t

Re: NSOperationQueue: -waitUntilAllOperationsAreFinished and -setSuspended:

2011-10-01 Thread Kyle Sluder
On Sat, Oct 1, 2011 at 3:44 PM, Quincey Morris wrote: > > Aren't you missing a [replyQueue setSuspended: NO] in there somewhere? And > if you do that, aren't you then failing to wait for backgroundQueue to > empty? Yes, sorry. The call to -setSuspended: happens right before -waitUntilAllOperation

Re: NSOperationQueue: -waitUntilAllOperationsAreFinished and -setSuspended:

2011-10-01 Thread Stevo Brock
er wrote: > >> NSOperationQueue backgroundQueue = /* some long-lived background queue */; >> NSOperationQueue replyQueue = [NSOperationQueue new]; >> int totalResult = 0; >> >> [replyQueue setSuspended:YES]; >> >> for (id foo in myFoos) { >> [backgroundQ

Re: NSOperationQueue: -waitUntilAllOperationsAreFinished and -setSuspended:

2011-10-01 Thread Quincey Morris
On Oct 1, 2011, at 15:06 , Kyle Sluder wrote: > NSOperationQueue backgroundQueue = /* some long-lived background queue */; > NSOperationQueue replyQueue = [NSOperationQueue new]; > int totalResult = 0; > > [replyQueue setSuspended:YES]; > > for (id foo in myFoos)

NSOperationQueue: -waitUntilAllOperationsAreFinished and -setSuspended:

2011-10-01 Thread Kyle Sluder
Hi all, Can't find an answer to this in the documentation. Does -waitUntilAllOperationsAreFinished pay heed to the -isSuspended state of the NSOperationQueue? I ask because I'm basically following this pattern to collect responses from multiple concurrent background operations in a t

Re: NSInvocationOperations mysteriously whacked out of NSOperationQueue

2011-09-14 Thread Jerry Krinock
On 2011 Aug 24, at 23:30, Ken Thomases wrote: > At a guess, the NSOperationQueue may be dequeuing operations using something > like -[NSMutableArray removeObject:] instead of -[NSMutableArray > removeObjectIdenticalTo:]. Thus, it is depending on -isEqual:. I further >

Re: NSInvocationOperations mysteriously whacked out of NSOperationQueue

2011-08-24 Thread Ken Thomases
On Aug 25, 2011, at 12:15 AM, Jerry Krinock wrote: > I discovered a bug in my app today caused by the following repeatable > behavior: When one particular NSInvocationOperation in an NSOperationQueue > executes, two others get whacked out of the queue, and thus never execute. > A

NSInvocationOperations mysteriously whacked out of NSOperationQueue

2011-08-24 Thread Jerry Krinock
SHORT STORY I discovered a bug in my app today caused by the following repeatable behavior: When one particular NSInvocationOperation in an NSOperationQueue executes, two others get whacked out of the queue, and thus never execute. LONG STORY Starting with an empty NSOperationQueue, which I

Re: NSOperationQueue and Synchronization Control

2011-05-06 Thread Nick
//apple_ref/doc/uid/1057i-CH8-SW1 2011/5/6 Bing Li : > Dear all, > > I am a new Cocoa developer on iPhone/iPad. I plan to use NSOperationQueue to > achieve the goal of concurrency. I am not sure if it is better since I also > know GCD is available. > > Moreover, I didn't

Re: NSOperationQueue and Synchronization Control

2011-05-06 Thread Matt Neuburg
On Sat, 07 May 2011 03:32:37 +0800, Bing Li said: >Dear all, > >I am a new Cocoa developer on iPhone/iPad. I plan to use NSOperationQueue to >achieve the goal of concurrency. I am not sure if it is better since I also >know GCD is available. > >Moreover, I didn't

Re: NSOperationQueue and Synchronization Control

2011-05-06 Thread Sean McBride
On Sat, 7 May 2011 03:32:37 +0800, Bing Li said: >I am a new Cocoa developer on iPhone/iPad. I plan to use NSOperationQueue to >achieve the goal of concurrency. I am not sure if it is better since I also >know GCD is available. > >Moreover, I didn't notice that Cocoa prov

NSOperationQueue and Synchronization Control

2011-05-06 Thread Bing Li
Dear all, I am a new Cocoa developer on iPhone/iPad. I plan to use NSOperationQueue to achieve the goal of concurrency. I am not sure if it is better since I also know GCD is available. Moreover, I didn't notice that Cocoa provided developers with synchronization controlling mechanisms.

Re: System resources and number of operations on an NSOperationQueue

2010-11-14 Thread James Bucanek
Antonio Nunes wrote (Sunday, November 14, 2010 11:18 AM -): The sweet spot may of course differ on different machines and systems, so that is where setMaxConcurrentOperationCount comes in handy. Not only will it vary from machine to machine, but it's goin

Re: System resources and number of operations on an NSOperationQueue

2010-11-14 Thread Ken Thomases
On Nov 14, 2010, at 12:39 PM, Antonio Nunes wrote: > On 14 Nov 2010, at 16:25, Ken Thomases wrote: > >> -[NSProcessInfo activeProcessorCount] > > I see there is also processorCount. The docs totally don't explain what the > difference is. Is an active processor one that is available for process

Re: System resources and number of operations on an NSOperationQueue

2010-11-14 Thread Antonio Nunes
but I don't think that matters anyway, since the computational part of the operation is almost negligible. It's writing the data to disk that is most likely causing contention. >> Also, is there a way to find out the number of cores on a machine so that I >> can set that as

Re: System resources and number of operations on an NSOperationQueue

2010-11-14 Thread Antonio Nunes
On 14 Nov 2010, at 16:16, James Bucanek wrote: > NSOperationQueue uses Grand Central Dispatch, which will attempt to > load-balance the number of running operations based on _CPU_ resources. > However, that doesn't mean GCD will (or even can) automatically find the most &

Re: System resources and number of operations on an NSOperationQueue

2010-11-14 Thread Ken Thomases
en the computation kicks in the system gets another chance to decide whether there are free resources to handle it. > Also, is there a way to find out the number of cores on a machine so that I > can set that as a hard limit of number of operations on an NSOperationQueue? -[NSProcess

  1   2   3   >