Re: Concurrent tasks are getting hung up
Re: Concurrent tasks are getting hung up
- Subject: Re: Concurrent tasks are getting hung up
- From: Steve Mills <email@hidden>
- Date: Thu, 09 Oct 2014 16:54:50 -0500
On Oct 9, 2014, at 15:07:01, Jens Alfke <email@hidden> wrote:
> First check the docs for the CGImage APIs to see what their thread-safety is like. I'm guessing you may need to create a new context for each different thread you use them in. That's relevant because if the operation queue allows operations to run in parallel, they're each effectively on a different thread.
Where does Apple usually put info about whether or not something is thread safe? I thought it was right in the docs after each routine. The one that's hanging for me is CGImageSourceCreateImageAtIndex. Here's the stack. All the stuck threads look like this one:
#0 0x00007fff8d46ca56 in semaphore_wait_trap ()
#1 0x00007fff90e69451 in _os_semaphore_wait ()
#2 0x00007fff97c83258 in dispatch_once_f ()
#3 0x00007fff90efc50f in readMakerNoteProps ()
#4 0x00007fff8bd982f9 in readMakerNoteProps ()
#5 0x00007fff8bd4834d in metadataFromDatablock ()
#6 0x00007fff8bd47bf8 in metadataFromDatablock ()
#7 0x00007fff8bd7afed in createMetadataFromDatabuffer ()
#8 0x00007fff8bd7194e in readExifData ()
#9 0x00007fff8bd705ff in initImageJPEG ()
#10 0x00007fff8bd6f1d6 in _CGImagePluginInitJPEG ()
#11 0x00007fff8bd4528c in makeImagePlus ()
#12 0x00007fff8bd6a469 in CGImageSourceCreateImageAtIndex ()
#13 0x00000001000052a0 in -[FFGraphicSearch doesImageMatchURL:] at /Users/tut/Dropbox/FotoFind/FotoFind/FFGraphicSearch.mm:161
#14 0x0000000100003324 in -[FFMainWindowController ifImageMatchesAddToResults:] at /Users/tut/Dropbox/FotoFind/FotoFind/FFMainWindowController.mm:228
#15 0x00007fff977059ac in __invoking___ ()
#16 0x00007fff97705814 in -[NSInvocation invoke] ()
#17 0x00007fff8d9c9484 in -[NSInvocationOperation main] ()
#18 0x00007fff8d920f31 in -[__NSOperationInternal _start:] ()
#19 0x00007fff8d920bdb in __NSOQSchedule_f ()
#20 0x00007fff97c8328d in _dispatch_client_callout ()
#21 0x00007fff97c877e3 in _dispatch_async_redirect_invoke ()
#22 0x00007fff97c8328d in _dispatch_client_callout ()
#23 0x00007fff97c85082 in _dispatch_root_queue_drain ()
#24 0x00007fff97c86177 in _dispatch_worker_thread2 ()
#25 0x00007fff8de69ef8 in _pthread_wqthread ()
It's waiting on a semaphore. Could that mean that readMakerNoteProps isn't thread safe? Is there a way to make just my call to CGImageSourceCreateImageAtIndex so it runs synchronously or something like that? It would slow down that portion of each thread, but the rest of it would still run concurrently.
> Also make sure that if you share mutable data structures between the operations (you mentioned an array) that all access to those is properly synchronized. Using an @synchronized block is an easy way to do that.
I've wrapped the only use of that array in @synchronized. Thanks.
--
Steve Mills
Drummer, Mac geek
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden