serial-processing

GCD serial queue does not seem to execute serially

坚强是说给别人听的谎言 提交于 2019-12-12 07:37:47
问题 I have a method that at times can be invoked throughout my code. Below is a very basic example, as the code processes images and files off of the iphone photo gallery and marks them already processed when done with the method. @property (nonatomic, assign) dispatch_queue_t serialQueue; .... -(void)processImages { dispatch_async(self.serialQueue, ^{ //block to process images NSLog(@"In processImages"); .... NSLog(@"Done with processImages"); }); } I would think that each time this method is

GCD serial queue does not seem to execute serially

只谈情不闲聊 提交于 2019-12-03 07:33:53
I have a method that at times can be invoked throughout my code. Below is a very basic example, as the code processes images and files off of the iphone photo gallery and marks them already processed when done with the method. @property (nonatomic, assign) dispatch_queue_t serialQueue; .... -(void)processImages { dispatch_async(self.serialQueue, ^{ //block to process images NSLog(@"In processImages"); .... NSLog(@"Done with processImages"); }); } I would think that each time this method is called I would get the below output... "In processImages" "Done with processImages" "In processImages"

Equivalent of GCD serial dispatch queue in iOS 3.x

北城余情 提交于 2019-11-30 12:48:44
Apple's Grand Central Dispatch (GCD) is great, but only works on iOS 4.0 or greater. Apple's documentation says, "[A] serialized operation queue does not offer quite the same behavior as a serial dispatch queue in Grand Central Dispatch does" (because the queue is not FIFO, but order is determined by dependencies and priorities). What is the right way to achieve the same effect as GCD's serial dispatch queues while supporting OS versions before GCD was released? Or put another way, what is the recommended way to handle simple background processing (doing web service requests, etc.) in iOS apps

Equivalent of GCD serial dispatch queue in iOS 3.x

左心房为你撑大大i 提交于 2019-11-29 17:47:22
问题 Apple's Grand Central Dispatch (GCD) is great, but only works on iOS 4.0 or greater. Apple's documentation says, "[A] serialized operation queue does not offer quite the same behavior as a serial dispatch queue in Grand Central Dispatch does" (because the queue is not FIFO, but order is determined by dependencies and priorities). What is the right way to achieve the same effect as GCD's serial dispatch queues while supporting OS versions before GCD was released? Or put another way, what is

NSOperationQueue serial FIFO queue

你说的曾经没有我的故事 提交于 2019-11-27 13:39:45
Is it possible to use an NSoperationQueue object as a serial FIFO queue by setting its maxConcurrentOperationCount to 1? I note that the docs state... For a queue whose maximum number of concurrent operations is set to 1, this equates to a serial queue. However, you should never rely on the serial execution of operation objects. Does this mean that FIFO execution is not guaranteed? In most cases, it will be FIFO. However, you can set up dependencies between NSOperations such that an operation submitted early will let other operations pass it by in the queue until its dependencies are satisfied

NSOperationQueue serial FIFO queue

末鹿安然 提交于 2019-11-26 18:18:42
问题 Is it possible to use an NSoperationQueue object as a serial FIFO queue by setting its maxConcurrentOperationCount to 1? I note that the docs state... For a queue whose maximum number of concurrent operations is set to 1, this equates to a serial queue. However, you should never rely on the serial execution of operation objects. Does this mean that FIFO execution is not guaranteed? 回答1: In most cases, it will be FIFO. However, you can set up dependencies between NSOperations such that an

Resolve promises one after another (i.e. in sequence)?

大城市里の小女人 提交于 2019-11-25 21:57:04
问题 Consider the following code that reads an array of files in a serial/sequential manner. readFiles returns a promise, which is resolved only once all files have been read in sequence. var readFile = function(file) { ... // Returns a promise. }; var readFiles = function(files) { return new Promise((resolve, reject) => var readSequential = function(index) { if (index >= files.length) { resolve(); } else { readFile(files[index]).then(function() { readSequential(index + 1); }).catch(reject); } };