mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
avoid needing to initialise main operation queue in main thread
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37555 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
dbc4a7033d
commit
1bd5683eea
2 changed files with 15 additions and 16 deletions
|
@ -554,7 +554,6 @@ GS_PRIVATE_INTERNAL(NSOperationQueue)
|
|||
|
||||
|
||||
@interface NSOperationQueue (Private)
|
||||
+ (void) _mainQueue;
|
||||
- (void) _execute;
|
||||
- (void) _thread;
|
||||
- (void) observeValueForKeyPath: (NSString *)keyPath
|
||||
|
@ -583,16 +582,18 @@ static NSOperationQueue *mainQueue = nil;
|
|||
|
||||
+ (id) currentQueue
|
||||
{
|
||||
if ([NSThread isMainThread])
|
||||
{
|
||||
return mainQueue;
|
||||
}
|
||||
return [[[NSThread currentThread] threadDictionary] objectForKey: threadKey];
|
||||
}
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (mainQueue == nil)
|
||||
if (nil == mainQueue)
|
||||
{
|
||||
[self performSelectorOnMainThread: @selector(_mainQueue)
|
||||
withObject: nil
|
||||
waitUntilDone: YES];
|
||||
mainQueue = [self new];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -874,17 +875,6 @@ static NSOperationQueue *mainQueue = nil;
|
|||
|
||||
@implementation NSOperationQueue (Private)
|
||||
|
||||
+ (void) _mainQueue
|
||||
{
|
||||
if (mainQueue == nil)
|
||||
{
|
||||
mainQueue = [self new];
|
||||
[[NSObject leakAt: &mainQueue] release];
|
||||
[[[NSThread currentThread] threadDictionary] setObject: mainQueue
|
||||
forKey: threadKey];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) observeValueForKeyPath: (NSString *)keyPath
|
||||
ofObject: (id)object
|
||||
change: (NSDictionary *)change
|
||||
|
@ -916,6 +906,8 @@ static NSOperationQueue *mainQueue = nil;
|
|||
{
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
|
||||
[[[NSThread currentThread] threadDictionary] setObject: self
|
||||
forKey: threadKey];
|
||||
for (;;)
|
||||
{
|
||||
NSOperation *op;
|
||||
|
@ -974,6 +966,7 @@ static NSOperationQueue *mainQueue = nil;
|
|||
}
|
||||
}
|
||||
|
||||
[[[NSThread currentThread] threadDictionary] removeObjectForKey: threadKey];
|
||||
[internal->lock lock];
|
||||
internal->threadCount--;
|
||||
[internal->lock unlock];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue