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];
|
[super awakeFromNib];
|
||||||
|
|
||||||
[self addObserver:self forKeyPath:@"arrangedObjects" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:nil];
|
[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
|
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
|
||||||
|
@ -82,6 +83,10 @@
|
||||||
[self updatePlaylistIndexes];
|
[self updatePlaylistIndexes];
|
||||||
[self updateTotalTime];
|
[self updateTotalTime];
|
||||||
}
|
}
|
||||||
|
else if ([keyPath isEqualToString:@"length"])
|
||||||
|
{
|
||||||
|
[self updateTotalTime];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updatePlaylistIndexes
|
- (void)updatePlaylistIndexes
|
||||||
|
|
|
@ -271,27 +271,23 @@
|
||||||
NSOperationQueue *queue;
|
NSOperationQueue *queue;
|
||||||
queue = [[[NSApplication sharedApplication] delegate] sharedOperationQueue];
|
queue = [[[NSApplication sharedApplication] delegate] sharedOperationQueue];
|
||||||
|
|
||||||
NSInvocationOperation *oldReadEntryInfoOperation = Nil;
|
|
||||||
for (PlaylistEntry *pe in entries)
|
for (PlaylistEntry *pe in entries)
|
||||||
{
|
{
|
||||||
NSInvocationOperation *readEntryInfoOperation;
|
NSInvocationOperation *readEntryInfoOperation;
|
||||||
readEntryInfoOperation = [[[NSInvocationOperation alloc]
|
readEntryInfoOperation = [[NSInvocationOperation alloc]
|
||||||
initWithTarget:self
|
initWithTarget:self
|
||||||
selector:@selector(readEntryInfo:)
|
selector:@selector(readEntryInfo:)
|
||||||
object:pe]autorelease];
|
object:pe];
|
||||||
if (oldReadEntryInfoOperation)
|
|
||||||
{
|
|
||||||
[readEntryInfoOperation addDependency:oldReadEntryInfoOperation];
|
|
||||||
[oldReadEntryInfoOperation release];
|
|
||||||
}
|
|
||||||
[readEntryInfoOperation addObserver:self
|
[readEntryInfoOperation addObserver:self
|
||||||
forKeyPath:@"isFinished"
|
forKeyPath:@"isFinished"
|
||||||
options:NSKeyValueObservingOptionNew
|
options:NSKeyValueObservingOptionNew
|
||||||
context:NULL];
|
context:NULL];
|
||||||
[queue addOperation:readEntryInfoOperation];
|
[queue addOperation:readEntryInfoOperation];
|
||||||
oldReadEntryInfoOperation = [readEntryInfoOperation retain];
|
|
||||||
|
[readEntryInfoOperation release];
|
||||||
}
|
}
|
||||||
[oldReadEntryInfoOperation release];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +319,6 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[pe setValuesForKeysWithDictionary:entryInfo];
|
[pe setValuesForKeysWithDictionary:entryInfo];
|
||||||
[playlistController updateTotalTime];
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -339,6 +334,7 @@
|
||||||
// stop observing
|
// stop observing
|
||||||
[object removeObserver:self forKeyPath:keyPath];
|
[object removeObserver:self forKeyPath:keyPath];
|
||||||
[self performSelectorOnMainThread:@selector(processEntryInfo:) withObject:object waitUntilDone:NO];
|
[self performSelectorOnMainThread:@selector(processEntryInfo:) withObject:object waitUntilDone:NO];
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue