From 94f177aa0e8350a9bba0790ee41b606c461a314f Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Tue, 25 Aug 2009 00:49:11 +0000 Subject: - Fix NSLock console lines - Speed up table content processing a bit - Make the table content download/processing determinate where an approximate row count is available - Clean up table content source, assuming MCPStreamingResult will remain in use --- Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 2 +- .../MCPKit/MCPFoundationKit/MCPStreamingResult.h | 33 +++++++++++----------- .../MCPKit/MCPFoundationKit/MCPStreamingResult.m | 7 +++-- 3 files changed, 23 insertions(+), 19 deletions(-) (limited to 'Frameworks/MCPKit') diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index a61f3223..4413e1c0 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -1485,7 +1485,7 @@ static void forcePingTimeout(int signalNumber) */ - (void)unlockConnection { - [queryLock unlock]; + [queryLock performSelectorOnMainThread:@selector(unlock) withObject:nil waitUntilDone:YES]; } #pragma mark - diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.h b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.h index ae296192..146f81e7 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.h @@ -29,27 +29,28 @@ @class MCPConnection; typedef struct SP_MYSQL_ROWS { - char *data; - unsigned long *dataLengths; - struct SP_MYSQL_ROWS *nextRow; + char *data; + unsigned long *dataLengths; + struct SP_MYSQL_ROWS *nextRow; } LOCAL_ROW_DATA; @interface MCPStreamingResult : MCPResult { - MCPConnection *parentConnection; - - MYSQL_FIELD *fieldDefinitions; - BOOL fullyStreaming; - BOOL dataDownloaded; - BOOL dataFreed; - LOCAL_ROW_DATA *localDataStore; + MCPConnection *parentConnection; + + MYSQL_FIELD *fieldDefinitions; + BOOL fullyStreaming; + BOOL connectionUnlocked; + BOOL dataDownloaded; + BOOL dataFreed; + LOCAL_ROW_DATA *localDataStore; LOCAL_ROW_DATA *currentDataStoreEntry; - LOCAL_ROW_DATA *localDataStoreLastEntry; - unsigned long localDataRows; - unsigned long localDataAllocated; - unsigned long downloadedRowCount; - unsigned long processedRowCount; - unsigned long freedRowCount; + LOCAL_ROW_DATA *localDataStoreLastEntry; + unsigned long localDataRows; + unsigned long localDataAllocated; + unsigned long downloadedRowCount; + unsigned long processedRowCount; + unsigned long freedRowCount; } - (id)initWithMySQLPtr:(MYSQL *)mySQLPtr encoding:(NSStringEncoding)theEncoding timeZone:(NSTimeZone *)theTimeZone connection:(MCPConnection *)theConnection; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m index e51785f8..3f3e2073 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m @@ -74,6 +74,7 @@ mTimeZone = [theTimeZone retain]; parentConnection = theConnection; fullyStreaming = useFullStreaming; + connectionUnlocked = NO; if (mResult) { mysql_free_result(mResult); @@ -122,9 +123,9 @@ /** * Deallocate the result and unlock the parent connection for further use */ - - (void) dealloc +- (void) dealloc { - [parentConnection unlockConnection]; + if (!connectionUnlocked) [parentConnection unlockConnection]; [super dealloc]; } @@ -169,6 +170,8 @@ // once all memory has been freed if (processedRowCount == downloadedRowCount) { while (!dataFreed) usleep(1000); + [parentConnection unlockConnection]; + connectionUnlocked = YES; return nil; } -- cgit v1.2.3