Changeset 3709
- Timestamp:
- 08/10/07 22:58:58 (1 year ago)
- Files:
-
- trunk/Chat Core/InterThreadMessaging.m (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Chat Core/InterThreadMessaging.m
r3262 r3709 56 56 57 57 static NSMapTable *pThreadMessagePorts = NULL; 58 static NSMapTable *pThreadRunLoops = NULL; 58 59 static pthread_mutex_t pGate; 59 60 … … 71 72 assert(nil != runLoop); 72 73 assert(NULL != pThreadMessagePorts); 74 assert(NULL != pThreadRunLoops); 73 75 74 76 pthread_mutex_lock(&pGate); … … 80 82 [port scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode]; 81 83 NSMapInsertKnownAbsent(pThreadMessagePorts, thread, port); 84 NSMapInsertKnownAbsent(pThreadRunLoops, thread, runLoop); 82 85 83 86 /* Transfer ownership of this port to the map table. */ … … 111 114 112 115 static void 113 removeMessagePortForThread (NSThread *thread , NSRunLoop *runLoop)116 removeMessagePortForThread (NSThread *thread) 114 117 { 115 118 NSPort *port; … … 122 125 port = (NSPort *) NSMapGet(pThreadMessagePorts, thread); 123 126 if (nil != port) { 127 NSRunLoop *runLoop = NSMapGet(pThreadRunLoops, thread); 124 128 [port removeFromRunLoop:runLoop forMode:NSDefaultRunLoopMode]; 129 NSMapRemove(pThreadRunLoops, thread); 125 130 NSMapRemove(pThreadMessagePorts, thread); 126 131 } … … 147 152 148 153 149 150 @interface NSThread (SecretStuff)151 - (NSRunLoop *) runLoop;152 @end153 154 154 155 @implementation InterThreadManager … … 165 166 NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks, 166 167 NSObjectMapValueCallBacks, 0); 168 pThreadRunLoops = 169 NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks, 170 NSObjectMapValueCallBacks, 0); 167 171 168 172 [[NSNotificationCenter defaultCenter] … … 180 184 181 185 thread = [notification object]; 182 runLoop = [thread runLoop]; 183 if (nil != runLoop) { 184 removeMessagePortForThread(thread, [thread runLoop]); 185 } 186 removeMessagePortForThread(thread); 186 187 } 187 188
