rendered paste bodystatic NSMapTable *pThreadMessagePorts = NULL;
@implementation InterThreadManager
+ (void) initialize {
pThreadMessagePorts = NSCreateMapTable(...);
}
@end
@implementation NSThread (InterThreadMessaging)
+ (void) prepareForInterThreadMessages
{
/* Force the class initialization. */
[InterThreadManager class];
createMessagePortForThread([NSThread currentThread], [NSRunLoop currentRunLoop]);
}
@end
static void
createMessagePortForThread (NSThread *thread, NSRunLoop *runLoop)
{
assert(NULL != pThreadMessagePorts); // This very, very occasionally fails. Does making pThreadMessagePorts volatile fix it?
}