Re: NSImage drawInRect deadlock

2016-08-10 Thread Doug Hill
> On Aug 10, 2016, at 4:49 PM, Graham Cox wrote: > > >> On 9 Aug 2016, at 4:05 AM, Andrew Keller wrote: >> >> In my app, I’m creating thumbnails of images. To do this in parallel, I’m >> using the global background dispatch queue: > > > Just to throw another consideration into the discusi

Re: NSImage drawInRect deadlock

2016-08-10 Thread Graham Cox
> On 9 Aug 2016, at 4:05 AM, Andrew Keller wrote: > > In my app, I’m creating thumbnails of images. To do this in parallel, I’m > using the global background dispatch queue: Just to throw another consideration into the discusion, you don’t say what the thumbnails are being used for. Typica

Re: NSImage drawInRect deadlock

2016-08-10 Thread Andrew Keller
Am 10.08.2016 um 2:48 vorm. schrieb Quincey Morris : > On Aug 9, 2016, at 20:47 , Andrew Keller > wrote: >> >> 2. When utilizing Mike’s approach to limiting the number of parallel tasks >> down to, say, 1-8, I have been completely unable to reproduce the deadlock.

Re: NSImage drawInRect deadlock

2016-08-09 Thread Quincey Morris
On Aug 9, 2016, at 20:47 , Andrew Keller wrote: > > 2. When utilizing Mike’s approach to limiting the number of parallel tasks > down to, say, 1-8, I have been completely unable to reproduce the deadlock. > 3. When utilizing Mike’s approach to limiting the number of parallel tasks, > Xcode is s

Re: NSImage drawInRect deadlock

2016-08-09 Thread Andrew Keller
Am 09.08.2016 um 7:38 nachm. schrieb Andrew Keller : > Am 09.08.2016 um 3:59 nachm. schrieb Kyle Sluder : >> On Tue, Aug 9, 2016, at 07:38 AM, Andrew Keller wrote: >> >>> I was under the impression from the docs that macOS >>> handles the thread pool “automatically”. >> >> Mike Ash did a good job

Re: NSImage drawInRect deadlock

2016-08-09 Thread Andrew Keller
Am 09.08.2016 um 3:59 nachm. schrieb Kyle Sluder : > On Tue, Aug 9, 2016, at 07:38 AM, Andrew Keller wrote: > >> I was under the impression from the docs that macOS >> handles the thread pool “automatically”. > > Mike Ash did a good job explaining why this isn’t as “automatic” as one > might thin

Re: NSImage drawInRect deadlock

2016-08-09 Thread Jens Alfke
>> I was under the impression from the docs that macOS >> handles the thread pool “automatically”. GCD’s pool does use a thread per CPU core … but only as long as none of the operations run for a long time. If its entire thread pool is busy for “a while” and there are more blocks waiting in the

Re: NSImage drawInRect deadlock

2016-08-09 Thread Kyle Sluder
On Tue, Aug 9, 2016, at 07:38 AM, Andrew Keller wrote: > Am 08.08.2016 um 8:12 nachm. schrieb Kyle Sluder : > > > > On Mon, Aug 8, 2016, at 05:11 PM, Jens Alfke wrote: > >> > >>> On Aug 8, 2016, at 2:54 PM, Aaron Tuller wrote: > >>> > >>> "The following classes and functions are generally not t

Re: NSImage drawInRect deadlock

2016-08-09 Thread Damien DeVille
You could change your code to use `NSBlockOperation`. You would then have an `NSOperationQueue` on which you could set the `maxConcurrentOperationCount` to whatever number makes sense for you. Damien On Tue, Aug 9, 2016, at 05:38 AM, Andrew Keller wrote: > Am 08.08.2016 um 8:12 nachm. schrieb Kyl

Re: NSImage drawInRect deadlock

2016-08-09 Thread Andrew Keller
Am 08.08.2016 um 8:12 nachm. schrieb Kyle Sluder : > > On Mon, Aug 8, 2016, at 05:11 PM, Jens Alfke wrote: >> >>> On Aug 8, 2016, at 2:54 PM, Aaron Tuller wrote: >>> >>> "The following classes and functions are generally not thread-safe. In most >>> cases, you can use these classes from any th

Re: NSImage drawInRect deadlock

2016-08-08 Thread Kyle Sluder
On Mon, Aug 8, 2016, at 05:11 PM, Jens Alfke wrote: > > > On Aug 8, 2016, at 2:54 PM, Aaron Tuller wrote: > > > > "The following classes and functions are generally not thread-safe. In most > > cases, you can use these classes from any thread as long as you use them > > from only one thread at

Re: NSImage drawInRect deadlock

2016-08-08 Thread Jens Alfke
> On Aug 8, 2016, at 2:54 PM, Aaron Tuller wrote: > > "The following classes and functions are generally not thread-safe. In most > cases, you can use these classes from any thread as long as you use them from > only one thread at a time." The images are only being used on one thread at a tim

Re: NSImage drawInRect deadlock

2016-08-08 Thread Aaron Tuller
On Aug 8, 2016, at 1:48 PM, Jens Alfke wrote: > On Aug 8, 2016, at 12:46 PM, Aaron Tuller > wrote: >> >> Search for NSImage here: >> >> https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html#/

Re: NSImage drawInRect deadlock

2016-08-08 Thread Jens Alfke
> On Aug 8, 2016, at 12:46 PM, Aaron Tuller wrote: > > Search for NSImage here: > > https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html#//apple_ref/doc/uid/1057i-CH12-126728 > >

Re: NSImage drawInRect deadlock

2016-08-08 Thread Aaron Tuller
Search for NSImage here: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html#//apple_ref/doc/uid/1057i-CH12-126728 It sounds like you may need to do this serially, or try setting the cache mode to NSImageCacheNeve

NSImage drawInRect deadlock

2016-08-08 Thread Andrew Keller
Hi all, In my app, I’m creating thumbnails of images. To do this in parallel, I’m using the global background dispatch queue: dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ @autoreleasepool { NSSize *thumbnailSize = // calculate thumbnail size