mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +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
|
@ -1,3 +1,9 @@
|
||||||
|
2014-01-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSOperation.m: Make sure current queue is set for threads
|
||||||
|
owned by a queue (and return the main queue for the main thread).
|
||||||
|
Avoid needing to create the main queue in the main thread.
|
||||||
|
|
||||||
2014-01-07 Richard Frith-Macdonald <rfm@gnu.org>
|
2014-01-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSObject.m: Fixed logic error in David's libobjc2 integration
|
* Source/NSObject.m: Fixed logic error in David's libobjc2 integration
|
||||||
|
|
|
@ -554,7 +554,6 @@ GS_PRIVATE_INTERNAL(NSOperationQueue)
|
||||||
|
|
||||||
|
|
||||||
@interface NSOperationQueue (Private)
|
@interface NSOperationQueue (Private)
|
||||||
+ (void) _mainQueue;
|
|
||||||
- (void) _execute;
|
- (void) _execute;
|
||||||
- (void) _thread;
|
- (void) _thread;
|
||||||
- (void) observeValueForKeyPath: (NSString *)keyPath
|
- (void) observeValueForKeyPath: (NSString *)keyPath
|
||||||
|
@ -583,16 +582,18 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
|
|
||||||
+ (id) currentQueue
|
+ (id) currentQueue
|
||||||
{
|
{
|
||||||
|
if ([NSThread isMainThread])
|
||||||
|
{
|
||||||
|
return mainQueue;
|
||||||
|
}
|
||||||
return [[[NSThread currentThread] threadDictionary] objectForKey: threadKey];
|
return [[[NSThread currentThread] threadDictionary] objectForKey: threadKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (void) initialize
|
+ (void) initialize
|
||||||
{
|
{
|
||||||
if (mainQueue == nil)
|
if (nil == mainQueue)
|
||||||
{
|
{
|
||||||
[self performSelectorOnMainThread: @selector(_mainQueue)
|
mainQueue = [self new];
|
||||||
withObject: nil
|
|
||||||
waitUntilDone: YES];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,17 +875,6 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
|
|
||||||
@implementation NSOperationQueue (Private)
|
@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
|
- (void) observeValueForKeyPath: (NSString *)keyPath
|
||||||
ofObject: (id)object
|
ofObject: (id)object
|
||||||
change: (NSDictionary *)change
|
change: (NSDictionary *)change
|
||||||
|
@ -916,6 +906,8 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||||
|
|
||||||
|
[[[NSThread currentThread] threadDictionary] setObject: self
|
||||||
|
forKey: threadKey];
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
NSOperation *op;
|
NSOperation *op;
|
||||||
|
@ -974,6 +966,7 @@ static NSOperationQueue *mainQueue = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[[NSThread currentThread] threadDictionary] removeObjectForKey: threadKey];
|
||||||
[internal->lock lock];
|
[internal->lock lock];
|
||||||
internal->threadCount--;
|
internal->threadCount--;
|
||||||
[internal->lock unlock];
|
[internal->lock unlock];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue