On Feb 5, 2010, at 12:24 PM, Ronald Oussoren wrote:

>> Is wx/Mac not already built upon Carbon/Cocoa APIs? Cocoa's GUI APIs 
>> certainly aren't thread-safe - all calls must go through the main thread - 
>> and I doubt Carbon's GUI APIs are any different. [...]
> 
> That's what I thought as well, Cocoa requires that GUI calls are made on the 
> main thread.  There are some calls that are allowed on a secondary thread, 
> but most of them require that the main thread runs a runloop as well.
> 
> <http://developer.apple.com/mac/library/documentation/cocoa/conceptual/Multithreading/AboutThreads/AboutThreads.html>
>  seems to suggest that you can call Carbon APIs from a thread other than the 
> main thread (that's the only way "Threads and Your User Interface" makes 
> sense).

Reading that section, I'm not sure it does. It starts by talking about GUI APIs 
in general, then goes onto discussing QuickTime APIs. But while the QT APIs may 
deal with audio-visual resources, most aren't responsible for displaying them 
on screen, so I think maybe they have their messages crossed a bit.

Anyway, I think it's the case that unless Apple's documentation explicitly 
states that a given API is thread-safe, you should assume it isn't. Some are, 
some aren't; it's my impression that GUI-related APIs tend to fall in the 
latter camp, which seems not unreasonable when you consider how they work. 
Though I still reckon redesigning the code to do all GUI stuff on the main 
thread will be the best solution for the OP, painful as that might be.

Regards,

has
-- 
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to