Skip to content

Commit

Permalink
Handle queue a little different.
Browse files Browse the repository at this point in the history
  • Loading branch information
emsquared committed Jul 29, 2012
1 parent 9ee90ee commit 0d7677d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 35 deletions.
56 changes: 23 additions & 33 deletions Classes/IRC/IRCWorld.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,38 @@ - (void)setServerMenuItem:(NSMenuItem *)item
{
if (self.serverMenu) return;

self.serverMenu = [[item submenu] copy];
self.serverMenu = [item.submenu copy];
}

- (void)setChannelMenuItem:(NSMenuItem *)item
{
if (self.channelMenu) return;

self.channelMenu = [[item submenu] copy];
self.channelMenu = [item.submenu copy];
}

#pragma mark -
#pragma mark View Run Loop

- (void)fireMessageQueue:(TVCLogController *)log
{
if (NSDissimilarObjects(log, self.selected.log)) {
if (log.queueInProgress == NO) {
if (log.messageQueue.count >= 25) {
static dispatch_once_t once;

/* Not 100% sure dispatch_once is
designed to do something like this. */
dispatch_once(&once, ^{
[log runMessageQueueLoop];
});
} else {
[log runMessageQueueLoop];
}
}
}
}

- (void)runMessageQueueLoop
{
/* Loop active view. */
Expand All @@ -177,41 +196,12 @@ - (void)runMessageQueueLoop
IRCTreeItem *active = self.selected;

if (PointerIsNotEmpty(active)) {
NSMutableArray *viewArray = [NSMutableArray array];

for (IRCClient *c in self.clients) {
[viewArray addPointer:(__bridge void *)(c.log)];

for (IRCChannel *u in c.channels) {
[viewArray addPointer:(__bridge void *)(u.log)];
[self fireMessageQueue:u.log];
}
}

NSArray *sortedViews = [viewArray sortedArrayUsingComparator:^NSComparisonResult(NSValue *a, NSValue *b) {
TVCLogController *la = [a pointerValue];
TVCLogController *lb = [a pointerValue];

return (la.messageQueue.count < lb.messageQueue.count);
}];

for (NSValue *pntr in sortedViews) {
TVCLogController *log = [pntr pointerValue];

if (NSDissimilarObjects(log, active.log)) {
if (log.queueInProgress == NO) {
if (log.messageQueue.count >= 25) {
static dispatch_once_t once;

/* Not 100% sure dispatch_once is
designed to do something like this. */
dispatch_once(&once, ^{
[log runMessageQueueLoop];
});
} else {
[log runMessageQueueLoop];
}
}
}
[self fireMessageQueue:c.log];
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<key>TXBundleBuildCodeName</key>
<string>Turtle Soup</string>
<key>TXBundleBuildNumber</key>
<string>12148</string>
<string>12166</string>
<key>TXBundleBuildReference</key>
<string>2.1.1-266-g6def6c7-appstore</string>
<string>2.1.1-267-g9ee90ee-appstore</string>
</dict>
</plist>

0 comments on commit 0d7677d

Please sign in to comment.