Updated playlistLoader to be CONCURRENT! Mwahahaha!
total time is now automatically updated by observing PlaylistController.arrangedObjects.lengthCQTexperiment
parent
6a4b661208
commit
276176a80c
|
@ -73,6 +73,7 @@
|
|||
[super awakeFromNib];
|
||||
|
||||
[self addObserver:self forKeyPath:@"arrangedObjects" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil];
|
||||
[self addObserver:self forKeyPath:@"arrangedObjects.length" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||
|
@ -82,6 +83,10 @@
|
|||
[self updatePlaylistIndexes];
|
||||
[self updateTotalTime];
|
||||
}
|
||||
else if ([keyPath isEqualToString:@"length"])
|
||||
{
|
||||
[self updateTotalTime];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updatePlaylistIndexes
|
||||
|
|
|
@ -271,27 +271,23 @@
|
|||
NSOperationQueue *queue;
|
||||
queue = [[[NSApplication sharedApplication] delegate] sharedOperationQueue];
|
||||
|
||||
NSInvocationOperation *oldReadEntryInfoOperation = Nil;
|
||||
for (PlaylistEntry *pe in entries)
|
||||
{
|
||||
NSInvocationOperation *readEntryInfoOperation;
|
||||
readEntryInfoOperation = [[[NSInvocationOperation alloc]
|
||||
readEntryInfoOperation = [[NSInvocationOperation alloc]
|
||||
initWithTarget:self
|
||||
selector:@selector(readEntryInfo:)
|
||||
object:pe]autorelease];
|
||||
if (oldReadEntryInfoOperation)
|
||||
{
|
||||
[readEntryInfoOperation addDependency:oldReadEntryInfoOperation];
|
||||
[oldReadEntryInfoOperation release];
|
||||
}
|
||||
object:pe];
|
||||
|
||||
[readEntryInfoOperation addObserver:self
|
||||
forKeyPath:@"isFinished"
|
||||
options:NSKeyValueObservingOptionNew
|
||||
context:NULL];
|
||||
[queue addOperation:readEntryInfoOperation];
|
||||
oldReadEntryInfoOperation = [readEntryInfoOperation retain];
|
||||
|
||||
[readEntryInfoOperation release];
|
||||
}
|
||||
[oldReadEntryInfoOperation release];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -323,7 +319,6 @@
|
|||
else
|
||||
{
|
||||
[pe setValuesForKeysWithDictionary:entryInfo];
|
||||
[playlistController updateTotalTime];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -339,6 +334,7 @@
|
|||
// stop observing
|
||||
[object removeObserver:self forKeyPath:keyPath];
|
||||
[self performSelectorOnMainThread:@selector(processEntryInfo:) withObject:object waitUntilDone:NO];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue