use connection pool for reads

pull/2/head
Michael Kirk 6 years ago
parent 2d86127324
commit 645a26cbdf

@ -52,6 +52,7 @@ void VerifyRegistrationsForPrimaryStorage(OWSStorage *storage)
@property (atomic) BOOL areAsyncRegistrationsComplete; @property (atomic) BOOL areAsyncRegistrationsComplete;
@property (atomic) BOOL areSyncRegistrationsComplete; @property (atomic) BOOL areSyncRegistrationsComplete;
@property (nonatomic, readonly) YapDatabaseConnectionPool *dbReadPool;
@end @end
@ -75,7 +76,7 @@ void VerifyRegistrationsForPrimaryStorage(OWSStorage *storage)
if (self) { if (self) {
[self loadDatabase]; [self loadDatabase];
_dbReadConnection = [self newDatabaseConnection]; _dbReadPool = [[YapDatabaseConnectionPool alloc] initWithDatabase:self.database];
_dbReadWriteConnection = [self newDatabaseConnection]; _dbReadWriteConnection = [self newDatabaseConnection];
_uiDatabaseConnection = [self newDatabaseConnection]; _uiDatabaseConnection = [self newDatabaseConnection];
@ -156,7 +157,8 @@ void VerifyRegistrationsForPrimaryStorage(OWSStorage *storage)
- (void)resetStorage - (void)resetStorage
{ {
_dbReadConnection = nil; _dbReadPool = nil;
_uiDatabaseConnection = nil;
_dbReadWriteConnection = nil; _dbReadWriteConnection = nil;
[super resetStorage]; [super resetStorage];
@ -426,6 +428,11 @@ void VerifyRegistrationsForPrimaryStorage(OWSStorage *storage)
return OWSPrimaryStorage.sharedManager.dbReadConnection; return OWSPrimaryStorage.sharedManager.dbReadConnection;
} }
- (YapDatabaseConnection *)dbReadConnection
{
return self.dbReadPool.connection;
}
+ (YapDatabaseConnection *)dbReadWriteConnection + (YapDatabaseConnection *)dbReadWriteConnection
{ {
return OWSPrimaryStorage.sharedManager.dbReadWriteConnection; return OWSPrimaryStorage.sharedManager.dbReadWriteConnection;

Loading…
Cancel
Save