Skip to content

Commit

Permalink
Merge pull request jgarth#2 from ternarylabs/bug-dequeing-order
Browse files Browse the repository at this point in the history
Fixed de-queuing order so that synchronous test will work
  • Loading branch information
Joachim Garth committed Mar 13, 2012
2 parents d4ec380 + 44f5272 commit 758d566
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions MCQueue.j
Expand Up @@ -16,7 +16,7 @@ var MCGlobalQueueObject = nil;
{
MCGlobalQueueObject = [[MCQueue alloc] init];
}

return MCGlobalQueueObject;
}

Expand All @@ -27,7 +27,7 @@ var MCGlobalQueueObject = nil;
_queuedRequests = [];
_processedRequests = [];
}

return self;
}

Expand All @@ -42,7 +42,7 @@ var MCGlobalQueueObject = nil;

// Attach it
[_queuedRequests addObject:request];

// If the queue was not stopped, process it immediately
if(_isRunning)
{
Expand All @@ -58,7 +58,7 @@ var MCGlobalQueueObject = nil;

// Attach it
[_queuedRequests addObjectsFromArray:requests];

// If the queue was not stopped, process it immediately
if(_isRunning)
{
Expand Down Expand Up @@ -104,14 +104,15 @@ var MCGlobalQueueObject = nil;
{
_currentRequest = [_queuedRequests objectAtIndex:0];

// Fire the next queued request
CPLog.debug("Starting request: " + _currentRequest);
[_currentRequest start];

// And get it off the heap, archive it
// Do this now because in case of synchronous callback we could end up here again
[_queuedRequests removeObject:_currentRequest];
[_processedRequests addObject:_currentRequest];

// Fire the next queued request
CPLog.debug("Starting request: " + _currentRequest);
[_currentRequest start];
}
}

@end
@end

0 comments on commit 758d566

Please sign in to comment.