Questions tagged [nsoperationqueue]

On Mac OS X, the NSOperationQueue class regulates the execution of a set of NSOperation objects.

The NSOperationQueue class regulates the execution of a set of NSOperation () objects. After being added to a queue, an operation remains in that queue until it is explicitly canceled or finishes executing its task. Operations within the queue (but not yet executing) are themselves organized according to priority levels and inter-operation object dependencies and are executed accordingly. An application may create multiple operation queues and submit operations to any of them.

References:

1047 questions
3
votes
1 answer

Why doesn't my NSOperationQueue stop executing when suspended?

I have a loop which I run and in each iteration I have a block that I want run on an NSOperationQueue. The underlying queue is serial. This loop could add hundreds of potentially long running block tasks. When I set m_opQueue.suspended = YES the…
Joey Carson
  • 2,973
  • 7
  • 36
  • 60
3
votes
0 answers

NSOperation finished KVO is sent on main thread

I have an asynchronous NSOperation in my app that executes an asynchronous method with a callback block that by default is executed on the main thread: - (void)start { self.executing = YES; [self.object doSomethingWithCallback:^{ //…
3
votes
1 answer

NSOperation with NSTimer loop how to stop it

I have NSOperationQueue that runs on another thread than the whole application. I'm adding NSOperation to the queue that in main has -(void)main{ [self updatePallets]; NSTimer * timer = [NSTimer scheduledTimerWithTimeInterval: 5.0…
3
votes
0 answers

Overriding 'finished' in asynchronous NSOperation

I've subclassed NSOperation, to perform an asynchronous operation. But I'm not clear on how I declare the operation to be finished. I overrided it as follows, but it just doesn't seem right that I should be manually calling willChangeValueForKey and…
Andrew
  • 7,693
  • 11
  • 43
  • 81
3
votes
1 answer

NSOperationQueue and Memory

I've been using an NSOperationQueue and I have very strange memory issue with it. I've tried reducing the issue to the simplest possible probleme and here I got: in init: _queue = [[NSOperationQueue alloc] init]; Later: TestOperation op =…
SeikoTheWiz
  • 853
  • 1
  • 10
  • 27
3
votes
1 answer

How can i set unique key values to NSOperation in iOS

In my app I'm trying to implement a NSOperationQueue for the web service interaction using AFNetworking. I'm adding a NSOperation one by one into the queue. I want to cancel a particular operation at any time. For that I want to set some unique key…
3
votes
2 answers

Any way to make dispatch_queue_t work in single thread?

Here is my code: @interface MyObject () @property(nonatomic) dispatch_queue_t queue; @end @implementation MyObject { NSThread *_check; } - (id)init { self = [super init]; if (self) { _queue =…
Kirow
  • 1,077
  • 12
  • 25
3
votes
1 answer

Multiple NSOperationQueues?

I would like to use NSOperations in my application to resolve threading problems. I have read some tutorials and now I know what I have to do, but I have a problem. There is a must to have the same NSOperationQueue in each class. What if I use a new…
3
votes
2 answers

object of class in NSOperationQueue - with asynchronous method using delegate

I have created a subclass of NSOperation named DownloadQueue. And i'm adding all objects one by one to NSOperationQueue which is appDelegate.queueDownload. Problem is when object of DownloadOperation is executed and as soon as download method of…
Akshit Zaveri
  • 4,166
  • 6
  • 30
  • 59
3
votes
2 answers

Understanding NSBlockOperation

I'm getting into NSBlockOperation and I have some questions. Notably, the documentation for addExecutionBlock says: Discussion The specified block should not make any assumptions about its execution environment. Calling this method while the…
3
votes
1 answer

NSOperationQueue inside NSOperation cause app freeze with waitUntilFinished:YES

I have NSOperation with AFHTTPClient request. In end of operation i need to perform another N operations with requests and wait that requests will be finished to mark main operation as finished @interface MyOperation :…
striker
  • 1,253
  • 3
  • 15
  • 25
3
votes
1 answer

Is -[NSOperationQueue currentQueue] reliable?

I know that GCD's dispatch_get_current_queue has been deprecated, and it is an anti-pattern to use it for callbacks anyway, but is -[NSOperationQueue currentQueue] reliable to use, or does it suffer from the same problems that GCD's…
Heath Borders
  • 30,998
  • 16
  • 147
  • 256
3
votes
2 answers

Unit tests for NSOperationQueue with maxConcurrentOperationCount

I have a class which is a kind of wrapper for NSOperationQueue. It allows to enqueue network requests using blocks. Currently the requests are executed one after another, but this can be changed in the future. Here is the code of MyRequestsQueue…
Michał Ciuba
  • 7,876
  • 2
  • 33
  • 59
3
votes
1 answer

NSOperation with dependency on another operation on a different queue does not start

I have dependency graph of operations and I use multiple queues to organize various streams of operations. E.g. peopleQueue, sitesQueue, sessionQueue sessionQueue: loginOp, fetchUpdatedAccountOp peopleQueue: mostFrequentlyManagedClientsOp,…
3
votes
3 answers

Perform synchronous operations

Say I want to implement a pattern like so: a = some array I download from the internet b = manipulate a somehow (long operation) c = first object of b These would obviously need to be called synchronously, which is causing my problems in Objective…
JoshDG
  • 3,871
  • 10
  • 51
  • 85