Scripting bridge: async support, as useful for long running tasks

Originator:amorya
Number:rdar://19397033 Date Originated:07-Jan-2015 10:45 AM
Status:Open Resolved:
Product:OS X SDK Product Version:Mac OS X 10.10.1 (14B25)
Classification:Enhancement Reproducible:Always
 
Within Scripting Bridge, please add some form of multithreading/async support for long running tasks. If only Cocoa used the async/await pattern, that’d be perfect. Without that, I’m seeing something with completion blocks — however we’d need a way to specify a bunch of operations to happen before then. I’m thinking of a situation like where I have about a dozen SB objects that represent messages in Mail. I want to get the body text for each one, via their content property. This is a time consuming operation, as Mail’s AppleScript is slow, so I’d like to do something in the background and be told when it’s done.

We should do something like NSManagedObjectContext’s performBlock: and performBlockAndWait: methods. Have those as methods on SBApplication, it can handle running its own background queue, and you can put whatever code you want in the block to access Scripting Bridge objects. If the developer wants to do something on the main thread of their app when all the scripting bridge fetching is done, they can add a dispatch_async() inside the block.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!